views:

100

answers:

2

What do I put in my .emacs file to use four spaces instead of the tab character for all indentation?

+5  A: 

This behavior is controlled by the variable indent-tabs-mode. Put:

(setq-default indent-tabs-mode nil)

in your .emacs to use spaces.

outis
Thanks! That gives me eight spaces instead of a tab, but how do I switch to four spaces?
knorv
Found the answer: (setq-default indent-tabs-mode nil)(setq-default tab-width 4)(setq indent-line-function 'insert-tab)
knorv
A: 

Please note that tabs and indentation in emacs is a more complicated subject than most people anticipate. I strongly recommend reading up on the subject at the Emacs Wiki, because the above information is far from comprehensive.

Phil