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?