Skip to content

Instantly share code, notes, and snippets.

@hileon
Forked from jessedearing/vim cheatsheet.md
Created March 27, 2012 04:12
Show Gist options
  • Save hileon/2212466 to your computer and use it in GitHub Desktop.
Save hileon/2212466 to your computer and use it in GitHub Desktop.
Vim Cheatsheet

#Vim Cheat Sheet

  • gqip - Reformats paragraph to textwidth
  • gq - Reformats selection
  • :Tab /= - Equally spaces based on the = symbol (requires Tabular vim plugin)
  • :setf language - Changes current language
  • :set language=language - Changes current language
  • <C-a> - Increments the number under the cursor
  • <C-x> - Decrements the number under the cursor

##Sed-style Replacements

  • s/<sed regex>/<replacement>/<flags>
    • <flags> - Can be a combintion of g for global (all occurances in a line, i to ignore case, and c to confirm each substitution

###Sed-style Regex

  • \? - 0 or 1
  • * - 0 or more
  • \+ - Matches one or more
  • \( \) - Captured grouping (can be used later in replacement with \1, \2, etc.
  • \%( \) - Non capturing group
  • ^ and $ - Beginning and end of line respectively

##Surround plugin

  • ys<motion or text><char to wrap> - Surrounds the text in the motion (Example: w for to the next word or $ to the end of the line) with the character, HTML tag, etc.
  • cs<old char><new char> - Changes the surrounding character
  • cst<html tag> - Changes an html tag from the current to a new one
  • ctrl-s - Adds a surrounding in insert mode

##Fugitive (Git extensions)

  • :Gdiff - Diffs file with current version in repository
  • :Gw - Saves and git adds
  • :Gco or :Gcommit - Commits

Three Way Diff

3 way reconciliation

##Ack.vim

o    to open (same as enter)
go   to preview file (open but maintain focus on ack.vim results)
t    to open in new tab
T    to open in new tab silently
v    to open in vertical split
gv   to open in vertical split silently
q    to close the quickfix window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment