How to capture shift-tab in vim

I want to use shift-tab to automatically complete and shift blocks of code visually. I meant Make_Shift-Tab_work . This link talks about displaying ^[[Z in shift-tab . But I do not get ^[[Z when I press shift-tab . I just get a normal tab in this case.

He then talks about using xmodmap -pke | grep 'Tab' xmodmap -pke | grep 'Tab' to match tab keys. Accordingly, the output should be

 keycode 23 = Tab or keycode 23 = Tab ISO_Left_Tab 

However i get

 keycode 22 = Tab KP_Tab 

if I use xmodmap -e 'keycode 22 = Tab ISO_Left_Tab' , and after that xmodmap -pke | grep 'Tab' xmodmap -pke | grep 'Tab' i still get

 keycode 22 = Tab KP_Tab 

This means that running xmodmap -e 'keycode 22 = Tab ISO_Left_Tab' no effect.

At the end, the link refers to xev to find out what X gets when I press shift-tab . But I do not have xev in my system.

Is there any other way to capture shift-tab in vim

+4
source share
1 answer

The link talks about getting ^[[Z when you press Ctrl + v Shift + Tab in insert mode. If you leave Ctrl + v , then Vim will behave as if you had pressed Tab .

The easiest way to get Vim to recognize <S-Tab> is to directly set the t_kB parameter to the escape sequence your terminal sends, rather than messing with cards.

As a quick test, try this in running Vim:

: set t_kB = Ctrl + v Esc [Z
: imap <S-Tab> Foo

Now, when you press Shift + Tab in insert mode, paste foo . If this works, you can make the change permanent by adding the following to your vimrc.

 exe 'set t_kB=' . nr2char(27) . '[Z' 
+2
source

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


All Articles