Binding special keys as vim shortcuts

[亡魂溺海] 提交于 2019-12-08 06:19:45

问题


My keyboard has extra hotkeys like "Back" and "Forward" that work in a web browser. I would like to use these types of keys as hotkeys in vim. How can I find out what vim sees these keys as so that they can be used as hotkeys in vim?


回答1:


Go to the command line, type control-k (you'll get a question mark on the command line), and then hit the key you're interested in. The question mark will be replaced with Vim's definition of what it receives.

In my experience, you won't get a response for every odd key. Also, for some keys you'll get a different response in gVim versus console Vim. I'm stuck on a Windows machine at work, but I sometimes SSH to our Linux server and use Vim there. In both gVim on Windows and console Vim on a Linux box, Vim says that the function key F7 is sending:

<F7>

And on Windows, when I type shift-F7, Vim reports:

<S-F7>

That all makes sense. But when I type shift-F7 on the console, it reports:

[31~

And after a lot of digging around, I found that to actually use the above value in a map I had to write it as:

<Esc>[31~

So my mapping to make F7 increment numbers and shift-F7 decrement numbers looks odd in console Vim:

map <F7> <C-A>
map <Esc>[31~ <C-X>

But it does work.



来源:https://stackoverflow.com/questions/9950944/binding-special-keys-as-vim-shortcuts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!