How to set Emacs tabs to spaces in every new file?

Peter picture Peter · Jun 18, 2009 · Viewed 12.1k times · Source

I would like to have an .emacs setting so that tabs are always formed by consecutive spaces. Preferably in each possible mode. In other editors it never seemed a problem, but in .emacs I'm a bit stuck with the tabs I'm afraid.

Answer

dfa picture dfa · Jun 18, 2009

add this in your .emacs:

(setq-default indent-tabs-mode nil)

or you can define a before-save-hook that eliminate hard tabs