I have some plugins installed, including NERDCommenter and NERDTree. I can't get the leader key to work right for them, though. These are the default configs when I type :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>
. I've tried remapping the leader key with the following in my .vimrc
in my home directory:
let mapleader = ","
This is reflected when I restart vim and type :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>
. What's going on and how do I fix this?
Edit: tested this in VIM as well with the same behavior.
Define mapleader
and maplocalleader
keys before any of the plugins are loaded.
Right on top of your .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
You may have set your timeout to zero. In that case, vim won't wait for the key after the 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.
For me, remapping the key code was the fix:
sudo setkeycodes 56 43
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With