Search code examples
vimkeymapping

Vim - How do I use a key mapping command like <C-L>?


I'm almost certain that someone else has also had this question, and this may be a repeat, but I'm not sure what to call a command like <C-L> and so I haven't had any luck finding an existing question. If this is a duplicate, please redirect me.

The question arises from a vimrc section that reads like this:

" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR><C-L>

So what combination of keys do I press (in which mode) to input a <C-L> mapping?


Solution

  • in this line:

    nnoremap <C-L> :nohl<CR><C-L>
    

    nnoremap means normal no-recursive map <C-L>... which means, if you press ctrl + l in NORMAL mode, the mapped key-strokes would be applied.

    <C-L> means ctrl + l

    if you type

    :h control
    

    you can see the keycodes:

    <C-...>     control-key         *control* *ctrl* *<C-*