让 emacs 总是插入(和退格)4 个空格制表符?

发布于 2024-10-07 21:59:33 字数 344 浏览 4 评论 0原文

我以为我已经设置好了,但是现在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

油焖大侠 2024-10-14 21:59:33

有问题的主要模式可能有自己的缩进规则,但如果我们谈论文本模式,那么确实应该调用 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 the tab-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 the ruler-mode-show-tab-stops variable, it may shed some light on things.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文