简体   繁体   中英

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. 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. For example, if you hit a tab at space 0, it will enter 4 spaces. If you are at space 1, it will only enter 3 spaces to get to the next tab guide.

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.

I've uploaded my Emacs settings here in case it helps :

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. 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 . That makes the behaviour of TAB depend on where in the line point is. 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. (It uses tabs if indent-tabs-mode is t , the default, and spaces if it is 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 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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