Calaf
Calaf

Reputation: 10817

Following up emacs TAB indentation with TABs, not spaces

If my .emacs contains just the lines

(setq-default indent-tabs-mode nil)
(add-hook 'text-mode-common-hook
          (lambda () (setq indent-tabs-mode t)))

I am expecting that if I edit a file list.txt containing

<tab> - Item 1
<tab> - Item 2

and press return after Item 2, a tab will be inserted on the next line, and not eight spaces.

But I get eight spaces, not a TAB.

How do I modify the .emacs above (for 24.5, if it matters) so that I get TABs?

Needless to say, I am trying to avoid C-q TAB. The idea is to automate the insertion of C-q TAB after a return, when needed.

Does something so simple really require smart-tabs?

I have asked this question in the past and was told that a .emacs such as the one above would solve the problem. It doesn't.

Upvotes: 0

Views: 125

Answers (1)

Chris
Chris

Reputation: 136889

text-mode-common-hook doesn't seem to exist. There is text-mode-hook, though.

This should work:

(setq-default indent-tabs-mode nil)
(add-hook 'text-mode-hook
          (lambda () (setq indent-tabs-mode t)))

Upvotes: 1

Related Questions