This is a card in Dave's Virtual Box of Cards.

Vim conveniences

Created: 2022-02-26

It’s almost impossible to overstate how much value you can get out of really simple Vim convenience mappings.

Edit .vimrc, source it to test changes

nnoremap <leader>rc :edit ~/.vimrc<cr>
nnoremap <leader>so :so %<cr>

Toggle spellchecking on/off with BONUS cheatsheet

The real killer feature here isn’t the shortcut, it’s that I also display a cheatsheet of the spellchecking commands! If I need to be reminded, I just hit F6 rapidly to turn spelling off and on again to see the cheatsheet.

nnoremap <F6> :setlocal spell! spelllang=en_us<CR>:echom "]s next, [s prev, z= list, zg add"<CR>

Use autocommands to do specific stuff on specific files

" Ziglings - tw=65 by default
au BufNewFile,BufRead */ziglings/* set textwidth=65

Run external commands to do stuff

" Publish gopher!
nnoremap <leader>gp :!gopherpub.sh %<cr>

Other

These two are a little longer (and even cooler), so they have their own cards:

  • vim-search-folding (generally useful!)

  • ratlink (more specific to this site, but the concept is probably broadly applicable)