Peter
Peter

Reputation: 49008

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

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.

Upvotes: 42

Views: 14546

Answers (2)

Trey Jackson
Trey Jackson

Reputation: 74480

Also of use, M-x untabify, which will convert all the tabs into spaces in the current region. You can use this to get rid of the existing tabs in files you've edited before you had the indent-tabs-mode set properly.

C-x h                   (M-x mark-whole-buffer)
M-x untabify

Upvotes: 41

dfa
dfa

Reputation: 116442

add this in your .emacs:

(setq-default indent-tabs-mode nil)

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

Upvotes: 62

Related Questions