Patricio Martins Logo
Back to articles

Vim — Most used commands for efficient text editing

Movement commands

Vim is known for fast navigation. Common movement keys:

Note: For uppercase letters, hold Shift.

  • h: left
  • j: down
  • k: up
  • l: right
  • w: next word
  • b: previous word
  • 0: start of line
  • $: end of line
  • gg: start of file
  • G: end of file
  • Ctrl+f: next page
  • Ctrl+b: previous page

Editing commands

  • i: insert before cursor
  • I: insert at start of line
  • a: insert after cursor
  • A: insert at end of line
  • o: new line below and insert
  • O: new line above and insert
  • r: replace character under cursor
  • s: delete char and insert
  • x: delete char under cursor
  • dw: delete word
  • dd: delete line
  • yy: yank (copy) line
  • p: paste after cursor
  • u: undo
  • Ctrl+r: redo

Save and quit

  • :w: write (save)
  • :q: quit
  • :wq: write and quit
  • :q!: quit without saving

Vim is a powerful, customizable editor that can significantly improve your efficiency.