代码之家  ›  专栏  ›  技术社区  ›  Nick Bolton

如何将.py文件的Emacs tab size设置为4个字符宽?

  •  23
  • Nick Bolton  · 技术社区  · 15 年前

    我尝试使用以下方法:

    (setq-default tab-width 4)
    (setq-default tab-stop-list (list 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
    

    如何使标签宽度为4个字符?

    我也试过,但没用:

    (add-hook 'python-mode-hook
      (setq indent-tabs-mode t)
      (setq tab-width 4)
    )
    
    4 回复  |  直到 5 年前
        1
  •  49
  •   sid-kap    7 年前
    (add-hook 'python-mode-hook
          (lambda ()
            (setq indent-tabs-mode t)
            (setq tab-width 4)
            (setq python-indent-offset 4)))
    
        2
  •  2
  •   Trey Jackson    15 年前

    (add-hook 'python-mode-hook
              (lambda ()
                (setq indent-tabs-mode t)
                (setq tab-width 4)))
    

    您需要将命令语句放入函数(lambda)中。

        3
  •  0
  •   T.E.D.    15 年前

    .emacs .

    (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.
    '(c-basic-offset 4 t)
    )
    

    实际上,我把它从C++模式区域中设置出来。 Customize Emacs py-basic-offset 或者别的什么?浏览pyton的模式设置。

        4
  •  0
  •   sid-kap    7 年前
    (setq indent-tabs-mode t)
    (setq python-indent-offset 4)