如何设置 emacs 在 verilog 模式下使用 3 个空格而不是制表符?
我对 emacs 还很陌生(使用版本 23.3),我想设置默认 tab 键以插入 3 个空格,而不是在 verilog 模式下插入制表符。我确实在堆栈溢出中找到了许多与此相关的帖子。其中一些是: -
但它们似乎不起作用Verilog 模式。这就是我的 .emacs 文件的样子。
(custom-set-variables
'(tab-stop-list ('(3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120)))
'(verilog-case-indent 3)
'(verilog-indent-level-directive 0)
'(verilog-indent-level 3)
'(verilog-tab-always-indent nil))
(custom-set-faces
)
(add-hook 'after-change-major-mode-hook
'(lambda ()
(setq-default indent-tabs-mode nil)
(setq tab-width 3)))
(setq-default indent-tabs-mode nil)
(setq-default tab-width 3)
(setq-default standard-indent 3)
如果我尝试编辑文本文件,设置会完美运行并插入 3 个空格而不是制表符。但是,当我尝试编辑 verilog 文件 (.v) 时,它仍然会插入制表符。我可以选择整个文本并执行 Mx untabify 以获得所需的结果,但是还有其他直接的解决方案吗?
I am pretty new to emacs (using version 23.3) and I wanted to set the default tab key to insert 3 spaces instead of a tab character in verilog mode. I did find a number of posts regarding this in stack overflow. Some of them are: -
How To Force spaces instead of tabs regardless of major mode
Why might my Emacs use spaces instead of tabs?
Emacs global configuration of tabs
But they do not seem to work in verilog mode. This is how my .emacs file looks like
(custom-set-variables
'(tab-stop-list ('(3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 93 96 99 102 105 108 111 114 117 120)))
'(verilog-case-indent 3)
'(verilog-indent-level-directive 0)
'(verilog-indent-level 3)
'(verilog-tab-always-indent nil))
(custom-set-faces
)
(add-hook 'after-change-major-mode-hook
'(lambda ()
(setq-default indent-tabs-mode nil)
(setq tab-width 3)))
(setq-default indent-tabs-mode nil)
(setq-default tab-width 3)
(setq-default standard-indent 3)
If I try to edit a text file, the setup works perfectly and inserts 3 spaces instead of a tab. However it still inserts a tab character when I try to edit a verilog file (.v). I can select the entire text and do M-x untabify to get the required result but is there another direct solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在钩子中,您应该使用
setq
而不是setq-default
,因此您需要将钩子重写为:PS 最好在钩子中使用专用函数,因为它是更容易更改它们,您也可以将它们从挂钩上移除
In the hook you should use
setq
instead ofsetq-default
, so you need to rewrite your hook to something like:P.S. it's better to use dedicated functions in hooks, as it's easier to change them, and you can also remove them from hooks