Search code examples
cemacscc-mode

Emacs indentation


In Emacs, the line gets indented only after hitting return (in cc-mode). Is that normal? Can that be changed to indent automatically when it hits a new line?

How do I look at variables, for example There are a number of predefined styles. Take a look at the variable ‘c-style-alist’ to see a list of them.?


Solution

  • in all of my programming mode hooks i have this line:

    (local-set-key [return] 'newline-and-indent)
    

    if for example, you wanted this in all "c" like modes, you would add this to your .emacs file:

    (add-hook 'c-mode-common-hook
              (lambda ()
                (local-set-key [return] 'newline-and-indent)))
    

    Second question:

    to describe something, you would use the help command. "v" gets help on variables, so you would use: M-x help v