← Main page

Vim

Movements

  • gg - go to the beginning of file
  • G - to to the end of file
  • :30 - go to the line #30
  • 0 - go to the beginning of line
  • ^ - go to the beginning of line (first not space character)
  • $ - go to the end of line
  • w or W - move to next word
  • b or B - move to previous word
  • H - move to the top of the screen
  • M - move to the middle of the screen
  • L - move to the bottom of the screen
  • { - jump to the previous empty line
  • } - jump to the next empty line
  • f then letter - jumps to letter forward
  • F then letter - jumps to letter backward
  • t and T do the same, but they stop before the character
  • % - go to matching parentheses
  • * - finds the word under cursor forward
  • # - finds the word under cursor backward

Edit

  • i - insert mode before current cursor position
  • I - insert mode in the beginning of line
  • a - insert mode after current cursor position
  • A - insert mode at the end of line
  • R - replace mode
  • r - replaces one character without entering replace mode
  • o - insert line after current line
  • O - insert line before current line
  • x - removes a symbol under cursor (like delete), 3x - removes 3 symbols to the right (current cursor position is included)
  • X - removes a symbol before cursor (like backspace), 3X - removes 3 symbols to the left (current cursor is NOT included)
  • u - undo
  • Ctrl+r - redo
  • dw - delete word forward
  • db - delete word backward d3b or 3db - delete 3 words backward
  • . - repeats the previous command
  • v - enters visual mode (you can use w, e, hjkl for movements, then you can press d for deleting or y for copying)
  • yy - copy line
  • p - put

Search

  • /phrase - searches phrase forward, n - continue search forward, N - continue search backward
  • ?phrase - searches phrase backward, n - continue search backward, N - continue search forward

Miscellaneous

  • :syntax on - switches syntax on
  • :syntax off - switches syntax off
  • :set number - shows line numbers
  • :set nonumber - disables line numbers