Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
221 lines (195 sloc) 5.15 KB
Vim Cheat Sheet
===============
Cheat sheet for my custom (and some standard) Vim commands.
Navigation
----------
% Match x
* Next occurrence
# Previous occurrence of text
g* Next occurrence (part of text)
g# Previous occurrence (part of text)
gd Go to definition (local scope)
gD Go to definition (global scope)
g, Go forward to latest edit
g; Go backward to latest edit
gg Go to top of buffer
G Go to bottom of buffer
[ Go to next method/section/paragraph
{ Go to next method/section/paragraph
( Go to next method/section/paragraph
S Replace line
s Replace char
. Repeat latest edit
Buffers
-------
,mr List of most recently used files
,t Fuzzy find file
C-w o Maximize buffer
C-tab Next buffer
C-S-tab Previous buffer
,bn Next buffer
,bp Previous buffer
,bc Close buffer
,ba Close all buffers
Windows
-------
C-w C-w Go to next window
C-l Go to right window
C-h Go to left window
C-j Go to upper window
C-k Go to lower window
Fugitive
--------
:Gcommit
:Gread
:Gwrite
:Gblame
:Gbrowse
:Gmove
:Gremove
:Gdiff
:Gstatus
:Ggrep
:Gsplit | Gvsplit
:Git
Fuzzy Finder
-----------
,t Find file recursively from CWD
,b :FufBuffer
,f :FufFile
,l :FufLine
,mr :FufMruFile
,dd :FufDir
,dr :FufDirWithFullCwd
,dc :FufDirWithCurrentBufferDir
Session
-------
:SaveSession <tab> Save session
:OpenSession <tab> Load session
:ViewSession View session
:CloseSession Close session
Registers
---------
“a y Yank into register a (replace)
“A y Yank into register A (append)
“a p Paste from register a
:registers Show all registers
Marks
-----
m<register> Set bookmark
'<register> Go to bookmark
:marks Show bookmarks
:delmarks a b c Delete marks a b c
:delmarks! Delet all marks
Tags
----
:tags Show all tags
C-] Go to next tag
C-t Go to previous tag
NERDTree
--------
,nt Toggle NERDTree
B Show bookmarks
C Set dir as top dir
cd Set dir as working dir
O Open file/folder
m Show menu
NERDCommmenter
--------------
,cc Comment out current line or selected lines in visual mode
,cn Same as ,cc but forces nesting
,c <space> Toggles the comment state of the selected line(s)
,cs Comments out the selected lines ‘sexily’
‘cu Uncomments the selected line(s).
LustyJuggler
------------
,lj (Quick) jump to open buffer (LustyJuggler)
,lf Opens the filesystem explorer.
,lr Opens the filesystem explorer from directory of the current file.
,lb Opens the buffer explorer
,lg Opens the buffer grep, for searching through all loaded buffers
Yank Ring
---------
,yr Opens list of yank ring
C-P Moves backward through the yank ring (after an initial paste)
C-N Moves forward through the yank ring (after an initial paste)
Surround
--------
ds” Delete surrounding “
cs{( Change surrounding { to (
ysiw( Wrap word in (
yss{ Wrap line in {
Compiling
---------
C-B Build
C-L Show error list
,cc Show cope (error list)
,n Jump to next error
,p Jump to previous error
Misc
----
,cd Set current file dir to current dir
gq<move> Format section over ‘movement’
,w Save buffer
gg=G Format the whole buffer
=i{ Format all within the {..} block
,e Edit vimrc
,t2 Set shiftwidth to 2 (t2 or t4)
,q Open scratchpad
,wm Remove Windows ^M
Grep/Search
----
:Ack ... Search with ack
space Search backwards
C-space Search forwards
,g Vimgrep
:vimgrep /pattern/[j][g] filepattern (use j for listing in quicklist)
Undo branching
--------------
g- Traverse all undos backwards
g+ Traverse all undos forwards
:undolist List all undo branches
:undo N Undo to number N in list
:earlier Ns
:earlier Nm
:earlier Nh
:later Ns
:later Nm
:later Nh
Spelling
--------
,ss Toggle spelling
,sn Next error
‘sp Previous error
Folding
-------
zc Close fold
zo Open fold
zM Close all folds
zR Open all folds
za Toggle fold
‘z Toggle fold
RestructuredText
----------------
h1..h5 Create reST style headings
:Vstm Open menu
:Vst head Show heading styles
:Vst doc Show table of contents
:Vst link Show all links
:Vst pdf|html|xml|latex Convert to X
ConqueTerm
----------
:ConqueTerm zsh Opens a terminal
:ConqueTermSplit zsh Opens a terminal in horizontal split
:ConqueTermVSplit zsh Opens a terminal in vertical split
Remote
------
:Nread remote.server.com jboner PASSWD path
:Nwrite remote.server.com jboner PASSWD path
vim ftp://...
Diff
----
vim -d f1 f2 Diff files
:diffsplit file Diff with horizontal split
:vert diffsplit f1 Diff with vertical split
:set scrollbind Set windows to be in sync
Jump to Line
Something went wrong with that request. Please try again.