改进Emacs中的选项卡 [英] Improved tab in Emacs

查看:104
本文介绍了改进Emacs中的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想覆盖emacs中的坏默认标签方案,以便它能像大多数其他编辑器(eclipse,notepad ++)一样工作。我想设置它,以便不管模式,标签将插入一个选项卡,按Enter将使我处于我当前的选项卡深度。



我尝试过,但它不执行任何操作:

 (global-set-key(kbdTAB)'tab-to-tab-stop)
(setq default-tab-width 4);; 8是太多的


解决方案

你到下一行并自动缩进,你可以把

 (global-set-key(kbdRET)'换行和缩进)

在您的 .emacs 。 [或者您可以点击 Cj 而不是Enter。]一旦你这样做,你将永远不需要手动插入选项卡,因为Emacs会自动缩进一个新的行到更深的深度一个开放大括号等。如果你想改变缩进,你可以点击TAB直到它使你进入正确的缩进,然后从那里开始输入。 [当你打开一个关闭大括号时,Emacs足够聪明,可以向后退一个缩进级别。]



你应该删除 -set-key(kbdTAB)'tab-to-tab-stop)为此工作。


I want to override the bad default tabbing scheme in emacs so that it will work like most other editors (eclipse, notepad++). I want to set it so that regardless of mode, tab will insert a tab, and pressing enter will keep me at my current tab depth.

I tried this, but it does nothing:

(global-set-key (kbd "TAB") 'tab-to-tab-stop)
(setq default-tab-width 4) ;; 8 is way too many

解决方案

To make the Enter key take you to the next line and indent it automatically, you can put

(global-set-key (kbd "RET") 'newline-and-indent)

in your .emacs. [Or you can hit C-j instead of Enter.] Once you have that, you'll never need to insert tabs manually, because Emacs automatically indents a new line to extra depth after an opening brace, etc. If you do want to change the indentation, you can hit TAB until it takes you to the right indentation, then start typing from there. [And when you type a closing brace, Emacs is smart enough to take that brace one indentation level backwards.]

You should remove the (global-set-key (kbd "TAB") 'tab-to-tab-stop) for this to work.

这篇关于改进Emacs中的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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