Wolf
Wolf

Reputation: 321

Changing tabbing space and hotkeys in Emacs for C++

I'm completely new to linux/emacs (Using GNU Emacs 24.4.1 on debian) and I'm finding it incredibly frustrating to use. I'm trying to program in C++, however I'm finding the tab spacing is very small, it's not even a tab it's literally just a single space how do I fix this? I've tried adding this to my .emacs file in home but it didn't fix anything:

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

Is it also possible to change copy/cut/paste/undo to the original

Upvotes: 0

Views: 205

Answers (2)

Andrew Stein
Andrew Stein

Reputation: 13140

To change the indentation of c-like modes (c, c++, java, etc.) use

(setq c-basic-offset 4)

Upvotes: 0

shemake
shemake

Reputation: 101

You can skip the config file for now and just use the GUI:

  • Options -> Customize Emacs -> Top-level Customization Group -> Editing -> Indent

You might also consider checking out "smart-tabs" if you want tab to insert spaces instead of tab characters: Smart Tabs (tabs for indentation, spaces for alignment) http://www.emacswiki.org/emacs/SmartTabs

As for changing the cut/copy/paste commands, try CuaMode (should be installed by default on Emacs 22.1.1 and later):

M-x cua-mode

That will change many of your editing hotkeys around to the more "standard" versions. See more info here: http://www.emacswiki.org/emacs/CuaMode

(I would, however, recommend against that, as it will delay the Emacs learning process. The standard commands become second-nature in a short while, and learning them will guarantee that you aren't stuck using nano or gedit if you have to shell into someplace with an older version of Emacs).

Upvotes: 1

Related Questions