How to change brace indentation levels in Emacs?

2020-05-20 11:49发布

I can't for the life of me find any answer to this through conventional Internet means, so I'm hoping for some help.

Emacs for me right now tends to do indentation on braces as follows:

if( ... )
  {

  }

Which I find incredibly irritating; I've never even seen this behaviour anywhere else. At any rate, the behaviour I'm expecting is,

if( ... )
{

}

If anyone knows how to modify this, it'd be greatly appreciated.

1条回答
你好瞎i
2楼-- · 2020-05-20 12:50

Basically you want:

(setq c-default-style "bsd"
  c-basic-offset 4)

For more indentation commands:

M-x c-set-style RET style RET

Select predefined indentation style style. Type ? when entering style to see a list of supported styles; to find out what a style looks like, select it and reindent some C code.

C-c C-o symbol RET offset RET

Set the indentation offset for syntactic symbol symbol (c-set-offset). The second argument offset specifies the new indentation offset.

source: http://www.phys.ufl.edu/docs/emacs/emacs_251.html

also: http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Commands.html

查看更多
登录 后发表回答