简体   繁体   中英

How to map <c-leader> in vim?

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)

<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 (ie \ ), you can use this:

nnoremap <c-\> :CtrlP<CR>

There are two issues, here:

  1. 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 = '<cp>'
  2. <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=" "

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM