vim Cheatsheet

Topics: vim

This cheatsheet lists common vim commands for navigation, text transformation, comments, spelling, and folding.

see vim

  • { - previous paragraph
  • } - next paragraph

Case transformation

  • gU - UPPER CASE
  • gu - lower case
  • g~ - toggle case

Replace tabs with spaces

:set expandtab
:set tabstop=2
:retab

tComment plugin

gc{motion} :: Toggle comments (for small comments within one line the &filetype_inline style will be used, if defined)
gcc :: Toggle comment for the current line
gC{motion} :: Comment region
gCc :: Comment the current line

Spelling

  • :setlocal spell spelllang=en_gb
  • ]s - Next error
  • [s - Previous error
  • zg - Learn word under cursor
  • zuw - Unlearn word
  • zw - Mark word under cursor as wrong
  • zug - Unmark word
  • z= - Suggest correction
  • 1z= - I feel lucky

Folding

https://vim.fandom.com/wiki/Folding

  • zc - close fold
  • zo - open fold
  • zM - close all folds
  • zR - open all folds
  • :set foldenable - enable folding
  • :set nofoldenable - disable folding