I've been unsuccessful in getting Emacs to switch from 8 space tabs to 4 space tabs when pressing the TAB in buffers with the major mode text-mode
. I've added the following to my .emacs
:
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
;;; And I have tried
(setq indent-tabs-mode nil)
(setq tab-width 4)
No matter how I change my .emacs
file (or my buffer's local variables) the TAB button always does the same thing.
As much as I love Emacs this is getting annoying. Is there a way to make Emacs to at least indent 4 space when there's not text in the previous line?
Do not confuse variable
tab-width
with variabletab-stop-list
. The former is used for the display of literalTAB
characters. The latter controls what characters are inserted when you press theTAB
character in certain modes.
(customize-variable (quote tab-stop-list))
or add tab-stop-list entry to custom-set-variables in .emacs file:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))))
Another way to edit the tab behavior is with with M-x edit-tab-stops
.
See the GNU Emacs Manual on Tab Stops for more information on edit-tab-stops
.