Skip to content

Instantly share code, notes, and snippets.

@sphingu
Last active November 9, 2024 13:13
Show Gist options
  • Save sphingu/9c70d1be91632243e5552168b3113e6c to your computer and use it in GitHub Desktop.
Save sphingu/9c70d1be91632243e5552168b3113e6c to your computer and use it in GitHub Desktop.
Vim Cheet Sheet

Vim Cheet Sheet

Modes

  • v - visual mode (V - visual line mode, C-V - visual block mode)
  • i - insert mode before cursor (I for beggining of the line)
  • a - insert mode after cursor (A for end of the line)
  • o - insert mode into new line bellow (O for new line above)
  • Esc - edit insert mode (or C-{)
  • 30i- Esc - insert 30 times dash(-)

Direction Movement

  • h - left
  • j - bottom
  • k - top
  • l - right
  • H - Top
  • M - Middle
  • L - Bottom
  • C-d - half page down
  • C-u - half page up
  • C-f - forward page
  • C-b - backward page
  • ( - move down statement () for up)
  • { - move down paragraph (} for up)

Word movement

  • w - word (3w)
  • b - word backward (2b)
  • e - word end (5e)

Character movement

  • 3fq - find & move to 3rd occurrence of q
  • 3Fq - find & move to previous 3rd occurrence of q

Line Movement

  • % - match brackets
  • $ - end of line
  • 0 - start of line
  • gg - start of line ([[ also does same)
  • G - end of line (]] also does same)

Search

  • /text - search text word
  • n - next search occurrence
  • N - previous search occurance
  • * - current word forward
  • # - current word backward

Delete

  • x - delete character under cursor
  • X - delete characters to the left of cursor
  • d - delete command (e.g.: d2w, d2e, etc) (diw, dis, dip - delete word, sentence or paragraph respectively)
  • dd - delete line
  • dtu - delete the text until character u

Bookmark

  • ma - bookmark position with key a (`a - to go to that bookmark)
  • `` - toggle between last two positions
  • `. - move to where last editing happened

Misc

  • . - repeast previous command
  • u - undo
  • C-r - redo
  • c - change word
  • ciw - change in word
  • s - replace character and enter into insert mode
  • r - replace character under cursor (without entering insert mode)
  • y - copy (yi{ - copy content between given braces (braces can be any)) (ya{ - will include braces as well in copy)
  • p - paste
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment