Vim Tip #1
I. Space is your Leader
Leader is an awesome idea. It allows for executing actions by key sequences instead of key combinations. Because I'm using it, I rarely need to press Ctrl-something combo to make things work.
For long time I used
, as my Leader key. Then, I realized I can map it to the most prominent key on my keyboard. Space.
let mapleader = "\<Space>"
This turned my Vim life upside down. Now I can press Leader with both of my thumbs, and my fingers are always on home row. Leader became so easy to use I began to notoriously use it in various keybindings.
II. Map your most frequent actions to Leader
I identified the actions that consumed most of my time while working in Vim. I mapped them using Leader key. Among others I decided to:
<Space>o to open a new file:
nnoremap <Leader>o :CtrlP<CR>
<Space>w to save file (a lot faster than
nnoremap <Leader>w :w<CR>
Copy & paste to system clipboard with
vmap <Leader>y "+y vmap <Leader>d "+d nmap <Leader>p "+p nmap <Leader>P "+P vmap <Leader>p "+p vmap <Leader>P "+P
Enter visual line mode with
nmap <Leader><Leader> V
I encourage you to identify your most frequent actions, and map them.
III. Use region expanding
I use terryma/vim-expand-region with following mapping:
vmap v <Plug>(expand_region_expand) vmap <C-v> <Plug>(expand_region_shrink)
It allows me to:
vto select one character
vagain to expand selection to word
vagain to expand to paragraph
<C-v>go back to previous selection if I went too far
It seems like vvv is slower than vp but in practice I don’t need to think beforehand what to select, and what key combination to use.
vat, ... you get the idea.