[英]Vim and GVim: leader key not working
I have some plugins installed, including NERDCommenter and NERDTree. 我安装了一些插件,包括NERDCommenter和NERDTree。 I can't get the leader key to work right for them, though.
但是,我不能让领导者的钥匙适合他们。 These are the default configs when I type
:map
当我输入
:map
时,这些是默认配置
v \c<Space> <Plug>NERDCommenterToggle
n \c<Space> <Plug>NERDCommenterToggle
v \cc <Plug>NERDCommenterComment
n \cc <Plug>NERDCommenterComment
\\c<space>
just works like hitting c<space>
. \\c<space>
就像点击c<space>
。 I've tried remapping the leader key with the following in my .vimrc
in my home directory: 我已经尝试使用我的主目录中的
.vimrc
中的以下内容重新映射领导键:
let mapleader = ","
This is reflected when I restart vim and type :map
当我重新启动vim并输入
:map
时会反映这一点
v ,c<Space> <Plug>NERDCommenterToggle
n ,c<Space> <Plug>NERDCommenterToggle
v ,cc <Plug>NERDCommenterComment
n ,cc <Plug>NERDCommenterComment
But still, ,c<space>
just behaves like I'm hitting c<space>
. 但是
,c<space>
只是表现得像我正在击中c<space>
。 What's going on and how do I fix this? 发生了什么,我该如何解决这个问题?
Edit : tested this in VIM as well with the same behavior. 编辑 :在VIM中测试它也具有相同的行为。
Define mapleader
and maplocalleader
keys before any of the plugins are loaded. 在加载任何插件之前定义
mapleader
和maplocalleader
键。
Right on top of your .vimrc! 就在你的.vimrc之上!
The mappings seem funny, I'd expect 我期待,这些映射看起来很有趣
v <Leader>c<Space> <Plug>NERDCommenterToggle
n <Leader>c<Space> <Plug>NERDCommenterToggle
v <Leader>cc <Plug>NERDCommenterComment
n <Leader>cc <Plug>NERDCommenterComment
for them to work. 让他们工作。 I suspect you are setting the mapleader after the plugins get loaded
我怀疑你在插件加载后设置了mapleader
You may have set your timeout to zero. 您可能已将超时设置为零。 In that case, vim won't wait for the key after the mapleader.
在那种情况下,vim将不会等待在mapleader之后的密钥。
:set timeout timeoutlen=0 ttimeoutlen=0
This will likely not be the answer for most but may help a small few... 这可能不是大多数人的答案,但可能会帮助少数......
I am running a debian distro (PureOS in my case, though the specific flavor may not totally matter) and the default \\
leader key is mapped to <
out of the box. 我正在运行debian发行版(在我的情况下是PureOS,虽然特定的味道可能并不完全重要)并且默认的
\\
leader键映射到<
开箱即用。
For me, remapping the key code was the fix: 对我来说,重新映射关键代码是修复:
sudo setkeycodes 56 43
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.