How do I make Emacs auto-indent my C code?

后端 未结 7 1085
一向
一向 2021-01-31 18:53

I\'m just starting to get a feel for emacs, but I am frustrated with it\'s tendency to not indent when I press the return key. I know if I press C-j it will do it, but I can\'t

相关标签:
7条回答
  • 2021-01-31 19:35

    In addition to the other suggestions, try C-c C-a to toggle the auto-newline feature so that your modeline reads C/la. Then you don't even need to press Enter most of the time; instead, when you type a semicolon or a brace, newlines get inserted and your code gets indented. Sometimes you do need to press Enter, and you don't get autoindentation (unless you rebind RET, as suggested in another answer) but if you just start typing the next line anyway, you may notice that it gets indented properly when you type some punctuation character.

    To get started with your "Lisp degree", type C-h i for the Info browser and go to the node for "CC Mode" (it is separate from the node for Emacs; type d for Directory and find CC Mode there).

    0 讨论(0)
提交回复
热议问题