Skip to content

vim Command Cheat Sheet

vim is a powerful terminal-based text editor.


Launch and Exit

vim filename.txt     # Open file
:q                   # Quit
:q!                  # Quit without saving
:w                   # Save
:wq or ZZ            # Save and quit

Insert Mode

  • i → Insert at cursor
  • I → Insert at line start
  • a → Append after cursor
  • A → Append at line end

  • h j k l → Left, down, up, right
  • 0, ^, $ → Line start, first non-space, end
  • gg, G → Top, bottom
  • :n → Go to line n

Editing

  • dd → Delete line
  • yy → Yank line
  • p → Paste
  • u → Undo
  • Ctrl+r → Redo

/pattern     # Search forward
?pattern     # Search backward
n/N          # Next/previous match