How to map <c-leader> in vim?
-
19-06-2021 - |
Question
I would like to map ctrl+leader key. Is it possible?
Tried: :nnoremap <c-leader> :CtrlP<CR>
And it does not work.
(ctrlp bindings conflict with yankring bindings)
Solution
<Leader>
is a special key notation in Vim; as such, it cannot be combined with modifiers such as C-
. Assuming the default setting for it (i.e. \
), you can use this:
nnoremap <c-\> :CtrlP<CR>
OTHER TIPS
There are two issues, here:
You didn't read CtrlP's documentation where you would have found this:
Use this option to change the mapping to invoke CtrlP in Normal mode: let g:ctrlp_map = '<c-p>'
<leader>
is supposed to be a cross-platform alternative to using the common modifier keys (Alt, Ctrl, Shift, Cmd) in mappings.Normally, you would use
<leader>
in place of<Ctrl>
as in:nnoremap <leader>p :CtrlP<CR>
This line in your ~/.vimrc
will probably solve your problem:
let g:crtlp_map='<F11>'
Though it won't help much here are my mappings for CtrlP:
nnoremap <leader>f :CtrlP<CR>
nnoremap <leader>b :CtrlPBuffer<CR>
nnoremap <leader>m :CtrlPMRUFiles<CR>
nnoremap <leader>t :CtrlPTag<CR>
For example to map leader key to space try this ...
let mapleader=" "