为什么我的Emacs会使用空格而不是标签? [英] Why might my Emacs use spaces instead of tabs?

查看:129
本文介绍了为什么我的Emacs会使用空格而不是标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试诊断这个问题。 TAB创建4个空格,而不是像我想要的4个TAB。但是我不认为这应该是因为 Ch v indent-tabs-mode 在缓冲区中有问题,它被设置为 t 。当我查看我的键盘绑定时,TAB设置为 c-indent-line-or-region 。这个功能是否忽略我的选项卡模式?

解决方案

Emacs中的标签和缩进比大多数人预期的要复杂得多。我强烈建议花一些时间阅读它 - 这几乎肯定会给你带来一些困惑,长远来说。



Emacs Wiki下面的页面大部分是相关讨论:
http://www.emacswiki.org/emacs/CategoryIndentation



这里有很多,但值得一提。



TabsAreEvil和SmartTabs配置很有可能吸引您,btw,具体取决于您对此主题的个人意见!



确保您阅读tab-stop-list上的页面变量。它靠近该链接列表的底部附近,但是在没有自动缩进规则的情况下,了解标签的行为以及tabify这一点非常重要。



标尺模式在这里也很有用。我使用文本模式自动启用它:

  ;;在文本模式中使用标尺
(add-hook'text-mode-hook
(function(lambda()
(setq ruler-mode-show-tab-stops t)
(标尺模式1))))


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?

解决方案

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.

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.

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!

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆