gpt4 book ai didi

Spacemacs 设置制表符宽度

转载 作者:行者123 更新时间:2023-12-02 19:44:10 26 4
gpt4 key购买 nike

我刚刚从 VIM 迁移到 Spacemacs,想将制表符宽度从默认值 (\t?) 更改为仅 2 个空格。我发现像这样的命令

(setq-default indent-tabs-mode nil)

(setq tab-width 4) ; or any other preferred value
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)

我的问题是我不知道它们是否正确,我应该将它们插入到 .spacemacs 文件中的哪个位置,以及它们的含义。

最佳答案

我找到了这篇文章: http://blog.binchen.org/posts/easy-indentation-setup-in-emacs-for-web-development.html

我将这部分代码添加到任何函数之外的 .spacemacs 文件中(但在 (defun dotspacemacs/user-init () ... ) 之前):

(defun my-setup-indent (n)
;; java/c/c++
(setq c-basic-offset n)
;; web development
(setq coffee-tab-width n) ; coffeescript
(setq javascript-indent-level n) ; javascript-mode
(setq js-indent-level n) ; js-mode
(setq js2-basic-offset n) ; js2-mode, in latest js2-mode, it's alias of js-indent-level
(setq web-mode-markup-indent-offset n) ; web-mode, html tag in html file
(setq web-mode-css-indent-offset n) ; web-mode, css in html file
(setq web-mode-code-indent-offset n) ; web-mode, js code in html file
(setq css-indent-offset n) ; css-mode
)

并添加了该行

(my-setup-indent 2) ; indent 2 spaces width

进入(defun dotspacemacs/user-init () ... ),如下所示:

(defun dotspacemacs/user-init ()
"Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
(my-setup-indent 2) ; indent 2 spaces width
)

关于Spacemacs 设置制表符宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36719386/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com