Insert spaces instead of TAB in Emacs viper mode

I have been a vim user for a long time and recently discovered that emacs has a viper mode offering the best of both worlds (at least for me). However, one thing really bothers me, since I mainly code in python, and mixing tabs and spaces is a big deal.

When in insert mode I would like to insert viper-shift width spaces instead of TAB when I press TAB. How can i do this? I suppose this is a simple lisp function / setting function.

I did not find anything in the viper-mode settings that could do this.

Edit:

I have (setq-default indent-tabs-mode nil)in my .emacs, but that does not work when I enter insert mode (in vim meaing in insert mode) in viper-mode

+3
source share
2 answers

First, you must make sure that the default 'indent-tabs-modevalue is equal nil, for example:

(setq-default indent-tabs-mode nil)

Then, in viper-mode, it also depends on yours viper-expert-level. At level 1 or 2 TABit turns out to be tied to 'self-insert-commandthrough a mode map viper-insert-diehard-minor-mode(which is activated when the expert level is 1 or 2). I assume it is trying to ensure maximum compatibility with vi, which means that you are sacrificing some Emacs features, including using some fairly simple settings.

So ... you can upgrade your expert level to 3 or higher:

(setq viper-expert-level 5)        ; really, why use anything less?

If you really need level 1 or 2, but want TAB to not be a self-insert command, add this to your .viper file:

(define-key viper-insert-diehard-map (kbd "TAB") 'viper-insert-tab)

, 1.

+6

indent-tabs-mode ?

, ?

, viper, M-x apropos, .

0

Source: https://habr.com/ru/post/1712038/


All Articles