Skip to content

Instantly share code, notes, and snippets.

@ergusto
Last active October 1, 2019 20:36
Show Gist options
  • Save ergusto/c7e5b4da2230a8035c4f31049ef9f9ec to your computer and use it in GitHub Desktop.
Save ergusto/c7e5b4da2230a8035c4f31049ef9f9ec to your computer and use it in GitHub Desktop.
An evolving Vim cheetsheet

Verbs, Nouns & Adverbs

  • dap - Delete Around Paragraph
  • yib - Yank In Brackets
  • yap - Yank Around Paragraph
  • das - Delete Around Sentence
  • di' - Delete in quotes
  • <ii - Shift current block to the left (provided by vim-indent-object)

Find & Search within file

  • f<x> - Go to next occurence of character
  • dt<x> - Delete up to, but not including, the next occurence of character x
  • df<x> - Delete to and including the next occurence of character x
  • * - Search for next occurence of word under cursor
  • /<word> - Search for word within file; pressing n to go to next occurence of word.
  • ?<word> - Search backwards for word within file; pressing n to go to previous occurence of word.

Search and replace within file

  • :%s/foo/bar/g - Find all global occurences of foo and replace with bar

Search for files from project root

  • :find filename.txt - Find filename from project root, with tab completion.

Buffers

  • :b partialFilename - Type fuzzy filename of an open buffer, tab to cycle through possible matches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment