Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The default format when I write a while statement is as follows:



I prefer to using the following:



Is there a way that I can customize emacs to following this format?

Thank you

share|improve this question
hmm.. which language and which major mode.? C and cc-mode ??. – kindahero Apr 16 '12 at 18:24

You can use c-set-style and friends to change which general style of indentation you want. You can also change individual pieces of the indentation engine to get something very personalized. See the EmacsWiki page for details. What you probably want (to a first approximation) is simply

(c-set-style "bsd")

in a hook, or

(setq c-default-style "bsd")

in your .emacs.

share|improve this answer
I have auto-complete setting that has known conflict with above solution. This solution solved my problem. – q0987 Apr 18 '12 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .