绑定特殊键作为vim快捷方式 [英] Binding special keys as vim shortcuts

查看:82
本文介绍了绑定特殊键作为vim快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的键盘上有一些额外的热键,例如后退"和前进",可在Web浏览器中使用.我想将这些类型的键用作vim中的热键.我如何找出vim认为这些键的内容,以便可以将它们用作vim中的热键?

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?

推荐答案

转到命令行,键入control-k(您将在命令行上看到一个问号),然后按您感兴趣的键输入.问号将替换为Vim对其接收内容的定义.

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.

根据我的经验,您不会收到每个奇数键的响应.另外,对于某些键,gVim和控制台Vim会得到不同的响应.我在工作的Windows机器上受困,但是有时我会通过SSH到我们的Linux服务器并在那里使用Vim.在Windows上的gVim和Linux上的控制台Vim中,Vim都说功能键F7正在发送:

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>

在Windows上,当我输入shift-F7时,Vim报告:

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

<S-F7>

这一切都说得通.但是,当我在控制台上键入shift-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~

所以在控制台Vim中,使F7递增编号和shift-F7递减编号的映射看起来很奇怪:

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>

但是确实可以.

这篇关于绑定特殊键作为vim快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆