Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change brace indentation levels in Emacs?

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.

like image 512
Elle H Avatar asked Mar 29 '10 23:03

Elle H


1 Answers

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

like image 139
Yuval Adam Avatar answered Oct 17 '22 22:10

Yuval Adam