让 emacs 总是插入(和退格)4 个空格制表符?
我以为我已经设置好了,但是现在 emacs 偶尔会插入一个 8 个字符的制表符,或者一个 6 或 5 个字符的制表符......
也许这是由文档引起的(这发生在一个大文本文件中,其中包含许多不同的制表符间距,尽管大多数是 4 个字符空间增量或常规制表符)。
(setq-default indent-tabs-mode 0)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
上面是我的 init.el 中的代码,这让我想知道为什么它偶尔会失败并插入 6 个字符制表符。
I thought I had this set fine, however now occasionally emacs will go and insert an 8 character tab, or a 6 or 5 character tab....
Maybe this is caused by the document (this has occurred in a large text file which contains many different tab spacings, though mostly 4 character space increments or regular tab characters).
(setq-default indent-tabs-mode 0)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
The above is the code from my init.el, which leads me to wonder why it is occasionally failing and inserting 6 character tabs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有问题的主要模式可能有自己的缩进规则,但如果我们谈论文本模式,那么确实应该调用
indent-line-function
(最终)。您可能需要仔细检查这不是缓冲区本地的,其值与您认为设置的值不同,但我想说更可能的罪魁祸首是tab-stop-list
变量。您可以在这里阅读有关该内容和其他相关内容的内容:
http://www.emacswiki.org/emacs/CategoryIndentation
它隐藏在靠近底部的位置该链接列表,但在没有自动缩进规则的情况下理解选项卡的行为至关重要。
如果您启用 Ruler-mode 和 Ruler-mode-show-tab-stops 变量,它可能会揭示一些情况。
The major mode in question might have its own rules for indentation, but if we're talking about text-mode then
indent-line-function
should indeed be called (eventually). You might want to double-check that this isn't buffer-local with a different value to the one you thought you'd set, but I would say the more likely culprit is thetab-stop-list
variable.You can read about that and other related things here:
http://www.emacswiki.org/emacs/CategoryIndentation
It's tucked away near the bottom of that list of links, but it's critical to understanding the behaviour of tabs in the absence of automated-indentation rules.
If you enable
ruler-mode
and theruler-mode-show-tab-stops
variable, it may shed some light on things.