Set 4 Space Indent in Emacs in Text Mode

后端 未结 20 2283
梦谈多话
梦谈多话 2020-11-29 15:27

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.

20条回答
  •  萌比男神i
    2020-11-29 15:29

    Add this to your .emacs file:

    This will set the width that a tab is displayed to 2 characters (change the number 2 to whatever you want)

    (setq default-tab-width 2)
    

    To make sure that emacs is actually using tabs instead of spaces:

    (global-set-key (kbd "TAB") 'self-insert-command)
    

    As an aside, the default for emacs when backspacing over a tab is to convert it to spaces and then delete a space. This can be annoying. If you want it to just delete the tab, you can do this:

    (setq c-backspace-function 'backward-delete-char)
    

    Enjoy!

提交回复
热议问题