I want to assign CTRL+L to go the next tab (:tabnext
). I placed it at ~/.vimrc
:
nmap <c-l> :tabnext<CR>
It worked fine, but I faced with a case when it doesn't work when I split screen on several windows. It seems that CTRL+L conflicts with "redraw screen" action assigned by default. For example, when I press CTRL+L on the center window I get nothing (see the screenshot):
但是,当我在左侧或右侧窗口上按相同的按钮时,它工作正常。
我想我需要“重写”默认操作,不是吗?
我从终端使用 vim。
如果我没记错的话,中间的窗口是 netrw(Vim 的标准文件管理插件)。它不是一个自定义插件,但它仍然是一个插件。
如果你看一下:help netrw-ctrl-l
,您将看到这不仅仅是重绘 - 它还刷新目录。因此它是从插件映射的,仅覆盖 netrw 窗口的默认 ctrl-l 映射。
如果你执行:verbose nmap <c-l>
在该窗口中,您将确切地看到它的定义位置:在autoload/netrw.vim
Vim 安装中的文件。在那里,我们发现了这个片段:
if !hasmapto('<Plug>NetrwRefresh')
nmap <buffer> <unique> <c-l> <Plug>NetrwRefresh
imap <buffer> <unique> <c-l> <Plug>NetrwRefresh
endif
这说的是,如果<Plug>NetrwRefresh
不绑定任何东西,然后绑定<c-l>
。这提供了一个简单的解决方案:因为netrw.vim
与其他所有内容一样,在之后加载.vimrc
,如果您将这些映射定义到其他某个键,它们将不会被分配给<c-l>
,并且您的映射不会被覆盖。所以只需在你的.vimrc
:
nmap <unique> <c-r> <Plug>NetrwRefresh
然而,更好的方法是不要踩到 Vim 的脚趾。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)