My Vim CheatSheet


My .vimrc can be found here.

General
  • ,: leader
  • ,ww: Write and save current file.
  • ,wa: Write and save all files in current vim session.
  • ,qa: Quit all files without writing.
  • ,do: Open the original file and diff it with the version in the buffer.
  • ,ex: Open built-in explorer in current window.
  • q:(q with a colon): access the vim command line history and you can move around and yank like with regular files.
  • ,rt: remove trailing spaces.
  • vat: Select current block, embedded with the nearest tag. (tags also selected). Then o/O go to beginning/end of the block.
  • vit: Select current block, embedded with the nearest tag. (tags Not selected). Then o/O go to beginning/end of the block.
Marking
  • ma: make a mark named "a". a-z are used within a file, A-Z are cross files.
  • `a: jump to the mark "a".
  • `` : jump to previous cursor position.
  • '': (Two single quotes). jump to the line-beginning of the previous cursor position.
  • `.: jump to position where last change occurred in current buffer.
Folding
  • za: toggle open/close for the current fold.
  • zfit: fold a section with enclosing tags, especially useful for html editing.
  • zR: open all folds.
  • zM: Re-enable all folds
Vimrc
  • ,ev: Open and edit .vimrc.
  • ,sv: Source .vimrc.
Sessions
  • ,ssv: Save the current session.
  • ,lsv: Load the saved session in pwd.
  • ,rsv: Save the current session, restart vim and reload the session.
Window Operations
  • c-[hjkl]: Move to the left/upper/lower/right window.
  • ,sp: Horizontally split current window.
  • ,vp: Vertically split current window.
Spell Check Operations
  • ,sc: Toggle spell check
  • zg: Add the current word into vocabulary.
  • z=: Prompt correction hints while the cursor is under a spell error.
  • ]s: Move to the next spell error.
  • [s: Move to the previous spell error.
Tab Operations
  • ,tn: Open a new tab.
  • ,m: Move to the previous tab.
  • ,n: Move to the next tab.
Highlighting
  • ,nh: Hide the highlighting after searching.
Plugins
WinManager
  • ,wm: Toggle winManager.
  • ,lu: Goto the left-upper most window, which would be the fileExplorer/bufExplorer.
  • ,lb: Goto the right-lower most window, which would be the tagList.
NetRW
  • ,fe: Toggle the Netrw filemanager.
Vim-autoformat
  • ,fm: Format the current file.
Python-mode
  • ,dc: Show documentation.
  • ,gd: Goto the definition.
  • ,r: Run the current code.
  • ,b: Add/remove breakpoint.
Latex Suite
  • ,ll: Compile all the way to pdf.
  • ,lf: Jump forward to the pdf and stop at the place corresponding to the source under cursor.
TComment
  • gcc: Comment current line.
  • gc[jk]: Comment the next/previous line.
Emmet-vim
  • ,em: leader key for emmet-vim. (replacing the default )
  • ,em,: expand an abbreviation, or wrap with tag (upon prompt) in visual selection mode.
  • ,emn: go to the next edit point in insert mode.
  • ,emN: go to the previous edit point in insert mode.
  • ,emm: merge selected lines into a single line.
  • ,emk: remove the content under cursor together with tag enclosing it.
  • ,ema: put url under cursor into an <a> tag, won't work with non-url.
Fugitive
  • ,gad: git add %
  • ,glg: git log
  • ,glo: git log --oneline
  • ,gst: git status
  • ,gwc: git whatchanged
  • ,grd: git checkout %
  • ,gcm: git commit %
  • ,gpom: git push origin master
vim-go
  • ,ggb :GoBuild
  • ,ggi :GoInstall
  • ,ggr :GoRun
  • ,ggt :GoTest

By