I want to map the <space>
key to <leader>
(which is currently the \\
key here) in VIM 7.4.
I would also like to be able to use both the <space>
and \\
keys as leaders.
If possible, it would be great to see the /
character appearing in the bottom right corner when I type it (instead of funky stuff like <20>
), but I can live without it.
I've tried to
nmap <space> <bslash>
this works for simple <leader>keys
commands, but <leader><leader>key
commands (like the easymotion maps) don't work.
I also tried to
let mapleader = " "
nmap <bslash> <space>
but analogously to the problem above stated, the <bslash>
key doesn't work anymore for <leader><leader>key
commands.
I already tried a bunch of stuff in these related questions/wiki pages:
I can't see your .vimrc
, so I can't guarantee this is the issue, but I would bet that the issue comes from using nnoremap
. The following works for me:
let mapleader =" "
nmap <leader>i iHello World<esc>
nmap <bslash> <space>
I can use either <space>i
or <bslash>i
and both of them run the iHello World<esc>
mapping. But this:
let mapleader =" "
nnoremap <leader>i iHello World<esc>
nnoremap <bslash> <space>
Does not work. <space>i
runs the mapping, but <bslash>i
does not, which is exactly what should be expected, since nnoremap
is used to avoid nested/recursive mappings. So one possible solution would be to use nmap
everywhere. I would definitely not recommend this, since you'll likely end up in a map loop. This solution should work better:
let mapleader =" "
nnoremap <leader>i iHello World<esc>
nmap <expr> <bslash> mapleader
Note that if you change the mapleader setting, this will break because, as :h mapleader
says:
Note that the value of "mapleader" is used at the moment the mapping is
defined. Changing "mapleader" after that has no effect for already defined
mappings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.