为什么我的 Emacs 可能使用空格而不是制表符? [英] Why might my Emacs use spaces instead of tabs?
问题描述
我正在尝试诊断此问题.TAB 创建 4 个空格而不是像我想要的 4 col TAB.但我不认为它应该是因为 C-h v indent-tabs-mode
在有问题的缓冲区上说它被设置为 t
.当我检查我的键绑定时,TAB 设置为 c-indent-line-or-region
.这个功能会忽略我的标签模式吗?
I am trying to diagnose this problem. TAB creates 4 spaces instead of a 4 col TAB like I want. But I don't think it should because C-h v indent-tabs-mode
on the buffer in question says it is set to t
. When I check my keybindings, TAB is set to c-indent-line-or-region
. Does this function ignore my tabs-mode?
推荐答案
Emacs 中的制表符和缩进是一个比大多数人预期的要复杂得多的主题.我强烈建议您花一些时间阅读它——从长远来看,它几乎肯定会为您省去一些困惑.
Tabs and indentation in Emacs is a considerably more complex subject than most people anticipate. I highly recommend spending some time reading about it -- it will almost certainly save you some confusion in the long run.
Emacs Wiki 的以下页面汇集了大部分相关讨论:http://www.emacswiki.org/emacs/CategoryIndentation
The following page at the Emacs Wiki groups together most of the relevant discussion: http://www.emacswiki.org/emacs/CategoryIndentation
那里有很多,但值得一看.
There's quite a lot there, but it's worth looking through.
顺便说一句,TabsAreEvil 和 SmartTabs 配置中的一个或其他很可能会吸引您,这取决于您对这个主题的个人看法!
One or other of the TabsAreEvil and SmartTabs configurations is quite likely to be appealing to you, btw, depending on your personal opinions on the subject!
确保您阅读了 tab-stop-list 变量上的页面.它隐藏在该链接列表的底部附近,但对于在没有自动缩进规则以及tabify"等内容的情况下理解制表符的行为至关重要.
Make sure you read the page on the tab-stop-list variable. 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, along with things like 'tabify'.
标尺模式在这里也很有用.我使用文本模式自动启用它:
ruler-mode is useful here as well. I enable it automatically with text-mode:
;; Use ruler in text-mode
(add-hook 'text-mode-hook
(function (lambda ()
(setq ruler-mode-show-tab-stops t)
(ruler-mode 1))))
这篇关于为什么我的 Emacs 可能使用空格而不是制表符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!