Emacs全局配置选项卡 [英] Emacs global configuration of tabs
问题描述
我试图从Vim切换到Emacs,但我正在撕裂我的头发,试图配置它来处理我想要的标签。我需要:
I'm attempting to switch from Vim to Emacs, but I'm tearing my hair out trying to configure it to treat tabs how I wish. I require:
- 插入标签以扩展为两个空格。 Emacs固执地坚持八个,不管我做了什么。
- 在屏幕上显示标签(即真实
\t
字符) 两个空格。 - 按TAB应该在光标中插入一个标签,而不是缩进整行。目前,我在任何地方按TAB,Emacs在该行开始时销毁所有的空格;这是迄今为止最令人激动的事情。
- Inserted "tabs" to be expanded into two spaces. Emacs stubbornly sticks to eight, no matter what I do.
- Tabs (i.e. real
\t
characters) to be represented on screen by two spaces. - Pressing TAB should insert a tab at the cursor rather than indent the entire line. Currently, I press TAB anywhere and Emacs destroys all whitespace at the start of the line; this is the most infuriating thing so far.
我目前的〜/ .emacs
读取
(setq standard-indent 2)
(setq-default indent-tabs-mode nil)
但是我没有尝试从网络结束建议的配置,没有一个完成他们说的话。 (API是否不断变化,我正在使用 GNU Emacs 23.1.1
,显然。)
but I have tried no end of suggested configurations from the web, none of which have done what they said they would. (Does the API constantly change? I'm using GNU Emacs 23.1.1
, apparently.)
推荐答案
Emacs非常灵活地支持处理缩进。一般来说,您所处的模式决定了它们的工作方式 - 所以如果您正在使用C文件,那么按Tab键的方式将与使用Python文件的方式不同。
Emacs has extremely flexible support for handling indentation. Generally the mode that you are in dictates how they work - so if you're working on a C file then the way that pressing tab works will be different than if you're working on a Python file.
所以它确实取决于你正在工作的模式,这将限制你得到的答案。在大多数情况下,我建议您不要与之对抗 - 对我来说,缩进行为是emacs最好的功能之一。但是,您需要花时间为自己定制。
So it does depend which mode you're working in, which will limit the answers you get. In most cases I would recommend that you don't fight against it - for me the indentation behaviour is one of the best features of emacs. However, you do need to spend the time to customize it for yourself.
要更改选项卡的显示方式,您需要将tab-width设置为2.如果编辑Java或C样式代码,那么听起来你想关闭所有这些漂亮的缩进功能到NIL:
To change the way that tabs are displayed you need to set tab-width to 2. If you're editing Java or C style code then it sounds like you want to turn off all the nice indentation features by these to NIL:
- c tab-always-indent
- c语法缩进
- indent-tabs-mode
我建议您通过自定义界面进行设置。如果您使用Mx自定义组RET C,则可以看到C模式的各种设置。
I suggest you set these through the customization interface. If you use "M-x customize-group RET C" then you can see the various settings for C mode.
如果您正在编辑不同类型的文件,那么说明将不同的。
If you're editting different types of files then the instructions will be different.
也许emacs的文件模式是错误的。您可以尝试使用M-x基本模式来查看您是否喜欢该行为。
Perhaps emacs is in the wrong mode for your file. You could try doing "M-x fundamental-mode" to see if you prefer the behaviour there.
这篇关于Emacs全局配置选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!