Skip to content

Instantly share code, notes, and snippets.

@mariofink
Last active March 11, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariofink/372104568780e26fa8846541c8e56e66 to your computer and use it in GitHub Desktop.
Save mariofink/372104568780e26fa8846541c8e56e66 to your computer and use it in GitHub Desktop.

VIM cheatsheet

Insert

  • i – before cursor
  • a – after cursor
  • O – above current line
  • o – below current line
  • I – beginning of line
  • A – end of line

Motions / Movement

  • w – start of next word
  • W – start of next Word (with punctuation)
  • e – end of next word
  • E – end of next Word (with punctuation)
  • b – start of previous word
  • B – start of previous word (with punctuation)
  • fx – next occurence of x
  • tx – 'til before next occurence of x
  • * – next occurence of word under cursor
  • # – previous occurence of word under cursor
  • :42 – Go to line 42
  • % – matching braces

Selectors

  • it – inside tag
  • at – around tag
  • iB or i{ – select inside block {"content"}
  • aB or a{ – select around block "{content}"
  • i( – select inside parentheses
  • a( – select around parentheses
  • i" – select inside quotes
  • a" – select around quotes

Find & replace

  • /searchterm – search for searchterm
  • n – go to next occurence of searchterm
  • N – go to previous occurence of searchterm
  • :s/find/replace/g – in current line
  • :%s/find/replace/g – in all lines

Buffers

  • bn – Go to next buffer
  • bd – Delete a buffer (that is, close the file)

Windows

  • ctrl + w + h/j/k/l – switch to window in specified direction

Other

  • u – Undo
  • ctrl + r – Redo
  • gg=G – Auto-indent
  • >aB – Indent block
  • . (full stop) – Repeat last command
  • gT – switch to next tab
  • gd – Go to definition
  • J - Join line (pull the next line up after the end of the current line).

Text objects

  • w – word
  • s – sentence
  • p – paragraph
  • t – tag

Compositions

  • daw – delete a word
  • ci" – change inside quotes

Actions (record & playback)

  • qa – Start recording your actions in register a
  • q – Stop recording
  • @a – Replay actions in register a

Plugin-specific

Ctrl-P

  • ctrl + f/b – Switch through modes
  • ctrl + T – Open in new tab
  • ctrl + V – Vertical split
  • ctrl + X – Horizontal split

surround.vim

  • yss<p> – Surround line with paragraph tag
  • yiw<em> – Surround word with emphasize tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment