简体   繁体   中英

How map <leader>char in Vim?

I just installed vim-indent-guides plugin.

The default mapping to toggle the plugin is <Leader>ig and I want to remap this to Ctrl-i.

These are my attempts:

nnoremap <C-i> <leader>ig
nnoremap <C-i> <Leader>ig

I have a similar approach to switch to relative numbers with Ctrl-n and it's working:

nnoremap <C-n> :set relativenumber!<ENTER>

What's wrong with the <Leader> key?

With :noremap , the original mapping isn't considered. Though :noremap is usually preferred to avoid interactions with other mappings, here you do need to allow remapping:

nmap <C-i> <leader>ig

This plugin offers a <Plug> mapping to facilitate remapping; then, the original <Leader>ig isn't even defined and free for other uses! Therefore, unless you want to have both , prefer this:

nmap <C-i> <Plug>IndentGuidesToggle

Note: This is all documented by the plugin under :help indent-guides-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.

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