Set 4 Space Indent in Emacs in Text Mode

后端 未结 20 2259
梦谈多话
梦谈多话 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条回答
  • 2020-11-29 15:33

    Have you tried

    (setq  tab-width  4)
    
    0 讨论(0)
  • 2020-11-29 15:34

    Modified this answer without any hook:

    (setq-default
      indent-tabs-mode t
      tab-stop-list (number-sequence 4 200 4)
      tab-width 4
      indent-line-function 'insert-tab)
    
    0 讨论(0)
  • 2020-11-29 15:41

    By the way, for C-mode, I add (setq-default c-basic-offset 4) to .emacs. See http://www.emacswiki.org/emacs/IndentingC for details.

    0 讨论(0)
  • 2020-11-29 15:42

    You may find it easier to set up your tabs as follows:

    M-x customize-group
    

    At the Customize group: prompt enter indent.

    You'll see a screen where you can set all you indenting options and set them for the current session or save them for all future sessions.

    If you do it this way you'll want to set up a customisations file.

    0 讨论(0)
  • 2020-11-29 15:44
    (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))))
    
    0 讨论(0)
  • 2020-11-29 15:45
    (setq tab-width 4)
    (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))
    (setq indent-tabs-mode nil)
    
    0 讨论(0)
提交回复
热议问题