vim 中的功能键映射

发布于 2024-09-15 09:38:34 字数 333 浏览 2 评论 0原文

我想使用以下条目映射 nerdtree 的 F2

map <F2> :NERDTreeToggle<CR>

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

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

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

map <F2> :NERDTreeToggle<CR>

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沙沙粒小 2024-09-22 09:38:34

你的问题是 vim 不知道当你按 时终端会发出什么。在某些终端上,它会发出类似 [12~ 的内容,因此 vim 退出当前模式(如果不能退出,则只是发出蜂鸣声)( ),不执行任何操作([1[ 之后必须有某个键,但不是 1,因此它不执行任何操作)并更改两个字母的大小写 (2 〜)。因此,您应该打开 .vimrc 并在其中写入以下内容:

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

其中 表示您必须按 ,然后按 。此行应该告诉 Vim 当您按 时终端发出的确切代码序列。之后,使用 noremap不管怎样,它应该可以工作。如果它不是您使用的唯一终端,那么您可能需要输入 if $TERM==#"=$TERM"此行之前和 endif 之后。

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>

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.

孤独岁月 2024-09-22 09:38:34
:map <F2> :NERDTreeToggle<CR>

启动 Vim 后,您可以查看

:map <F2>

F2 映射到的内容。插件可能会更改映射(在 .vimrc 中不可见)

:map <F2> :NERDTreeToggle<CR>

After starting Vim you can look with

:map <F2>

what F2 is mapped to. It is possible that the plugins change the mapping (not visible in .vimrc)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文