vim中的映射功能键 [英] mapping function keys in vim

查看:60
本文介绍了vim中的映射功能键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用以下条目将 F2 映射到 nerdtree:

I want to map my F2 for nerdtree with the following entry:

map <F2> :NERDTreeToggle<CR>

但即使在此之前,并在保存 vimrc 之后,每当我按 F2 时,它只会切换光标所在字母的大小写.后来发现任何功能键都可以.F5 切换 5 个字符的大小写等.这是因为其他一些插件吗?我目前使用 c.vim 、 snippetsEmu 、 around 、 nerdtree 和 minibufexpl

But even before that, and after saving the vimrc , whenever i press F2, it just switches the case of the letters on which the cursor is present. Later found out that any function key does it. F5 switches case of 5 characters and so on. Is this because of some other plugin? I presently use c.vim , snippetsEmu , surround , nerdtree , and minibufexpl

我的 vimrc 中没有任何功能键的键映射.

There are no keymappings to any function key in my vimrc.

推荐答案

你的问题是 vim 不知道当你按下 时终端会发出什么.在某些终端上,它会发出类似 <Esc>[12~ 的信息,因此 vim 退出当前模式(如果不能,则只发出哔哔声)(),什么都不做([1:[ 之后肯定有一些键,但不是 1,所以什么都不做)并改变两个字母的大小写(2~).因此,您应该打开 .vimrc 并在其中写入以下内容:

Your problem is that vim does not know what does terminal emit when you press <F2>. On some terminals it emits something like <Esc>[12~, so the vim quits current mode (or just beeps if it can't) (<ESC>), does nothing ([1: there must be some key after [, but not 1, so it does nothing) and changes case of two letters (2~). So, you should open .vimrc and write there the following:

set <F2>=<C-v><F2>

其中 表示您必须按 然后按 .这一行应该告诉 Vim 当你按下 时终端发出的确切代码序列.之后,使用 noremap 无论如何,它应该可以工作.如果它不是您使用的唯一终端,那么您可能需要输入 if $TERM==#"<C-r>=$TERM<CR>" 在此行之前,endif 在此行之后.

where <C-v><F2> means that you must press <C-v> and then <F2>. This line should tell the Vim the exact sequence of codes which is emitted by terminal when you press <F2>. After that, use noremap <F2> whatever and it should work. If it is not the only terminal that you are using, then you may want to put if $TERM==#"<C-r>=$TERM<CR>" before this line and endif after.

这篇关于vim中的映射功能键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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