06 - Leaders
Created Sunday 08 June 2014
Basically -, H, <space>, <cr>, <bs> do things that you almost never need in normal mode. But that only give us 6 keys to work with.
Mapping key sequences
Pick a key that you don't care about (like '-') as a "prefix" key and create mappings on top of it.
- :nnoremap -d dd
- :nnoremap -c ddO
Vim calls this "prefix" key the "leader".
- :let mapleader = "-"
- :nnoremap <leader>d dd
Vim has a second "leader" key called "local leader". This is meant to be a prefix for mappings that only take effect for certain types of files, like Python files or HTML files.
- :let maplocalleader = "\\" — one "\" for escaping
- :h mapleader
- :h maplocalleader