views:

161

answers:

1

I'm new to the whole Emacs thing, and one of the things that gets me is that out-of-the-box Emacs doesn't keep you within blocks when programming. I program in mostly Python and C++ and hitting enter sends the cursor back to column 1 on a new line rather than keeping you in the block you're working in. I managed to find this:

(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-m" 'newline-and-indent)))

Which binds the enter key to newline-and-indent in Python mode, but how do I extend this to cover C/C++ mode too?

+5  A: 

The following is from my init.el for xemacs, it might or might not work for emacs:

(add-hook 'c-mode-common-hook
      '(lambda () 
         (define-key c-mode-base-map (kbd "RET") 'newline-and-indent)))
Jose M Vidal
Bingo! That did the trick, thanks a bunch.
cornjuliox