Emacs auto-indent tabs instead of spaces

1.3k views Asked by At

I'm about to set EMACS put tabs instead of spaces when auto-indent, but cannot find any clue in the manual.

I tried this: (setq standard-indent 8) (setq-default tab-width 8), but somewhy there is still 2 characters instead of 8, and they are spaces, not tabs.

2

There are 2 answers

1
AudioBubble On

Major modes can override indentation settings. Whatever major mode you are using apparently overrides the indentation offset as well as indent-tabs-mode.

To re-enable tabs again, define the following function, and add it the hook of the affected major mode:

(defun my-enable-tabs ()
  (setq indent-tabs-mode t))

Take care, though, because a major mode normally has a good reason to apply specific indentation setting.

0
Drew On

Use this in your init file (~/.emacs), to turn off indent-tabs-mode by default, everywhere.

Yes, as @lunaryorn notes, other code (e.g. a mode) can override this default setting. But it is still your friend, so you start out right, everywhere.