简体   繁体   English

在Emacs功能中使Tab键类似于Notepad ++

[英]Make tab key in Emacs function similar to Notepad++

I've been trying to find a way to get my Emacs to function similar to notepad++ when tabbing. 我一直在尝试寻找一种方法来使我的Emacs在跳动时具有类似于notepad ++的功能。 Specifically, I want a tab to ALWAYS insert spaces when pressed, regardless of where I am in the file. 具体来说,无论我在文件中的哪个位置,我都希望选项卡在按下时始终插入空格。

Currently, I find that tabs only works in specific situations and even then the amount of space inserted is not consistent. 目前,我发现制表符仅在特定情况下可用,即使那样,插入的空间量也不一致。

Ideally, the tab press would function similar to notepad++ with where it stops too. 理想情况下,Tab键的功能与notepad ++相似,但也会停止。 For example, if you hit a tab at space 0, it will enter 4 spaces. 例如,如果您在空格0处单击一个选项卡,它将输入4个空格。 If you are at space 1, it will only enter 3 spaces to get to the next tab guide. 如果您位于空格1处,它将仅输入3个空格以转到下一个选项卡指南。

I don't know if the issue has to do with me using verilog-mode.el, but I've tried a bunch of different combinations and can't get it to work. 我不知道该问题是否与使用verilog-mode.el有关,但我尝试了很多不同的组合,但无法使其正常工作。

I've uploaded my Emacs settings here in case it helps : 我在这里上传了我的Emacs设置,以防万一:

https://github.com/TreverWagenhals/TreverWagenhals/tree/master/Emacs https://github.com/TreverWagenhals/TreverWagenhals/tree/master/Emacs

I'm sorry if this appears as a duplicate question, but I've tried a lot of suggestions on the internet and nothing has done what I want it to. 很抱歉,如果这是一个重复的问题,但是我在互联网上尝试了很多建议,却没有做任何我想做的事情。

By default, pressing TAB makes Emacs indent the current line. 默认情况下,按TAB可使Emacs缩进当前行。 That is, it tries to figure out how far the line should be indented (based on the surrounding lines and any mode-specific indentation settings), and then adds or removes tabs and/or spaces to get to the right indentation level. 也就是说,它试图找出应该缩进多远的线(基于周围的线和任何特定于模式的缩进设置),然后添加或删除制表符和/或空格以达到正确的缩进级别。

If you occasionally find that behaviour useful, you can set the variable tab-always-indent to nil . 如果偶尔发现该行为有用,则可以将变量tab-always-indentnil That makes the behaviour of TAB depend on where in the line point is. 这使得TAB的行为取决于线点在哪里。 If point is at the beginning of the line, it indents the line as described above, and otherwise it inserts a tab or spaces to get to the next tab stop. 如果point在行的开头,则如上所述缩进该行,否则它将插入一个制表符或空格以到达下一个制表位。 (It uses tabs if indent-tabs-mode is t , the default, and spaces if it is nil .) (如果indent-tabs-mode为默认值t ,则使用制表符;如果为nil ,则使用空格。)

If you don't need the indentation behaviour at all, you can rebind the TAB key to tab-to-tab-stop , which is normally bound to Mi : 如果根本不需要缩进行为,则可以将TAB键重新绑定到tab-to-tab-stop ,该键通常绑定到Mi

(global-set-key (kbd "TAB") 'tab-to-tab-stop)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM