Indent preprocessor directives as C code in emacs

a 夏天 提交于 2019-12-01 06:31:49
Ring Ø

You can simply tell Emacs to add an offset to the pre-processor lines.

  • Put the cursor (point) in a pre-processor line
  • then press C-c C-o (control-c control-o)
  • the minibuffer should say Syntactic symbol to change:,
  • type cpp-macro, press Enter
  • Enter the new offset (number - usually 0)

Then a TAB on each pre-processor line should indent it correctly. (or M-xindent-region ...).

To have the change set permanently, you can for instance add the required lines in your .emacs file.
An easy way to copy a previously entered command is c-x ESC ESC and use the arrow keys to find the (c-set-offset ...) Elisp command.

That should be

(c-set-offset (quote cpp-macro) 0 nil)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!