Show Menu
Cheatography

ultimate vim Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

General

Leader Key
,
Fast Saving
,w
Sudo Saving
:W

Visual Mode

Search for Current Selection
* or #
Search Forwards
<sp­ace>
Search Backwards
Ctrl-<­Spa­ce>
Ack Text (search for Text)
,gv
Search & Replace Selected Text
,r
Surround selection in ( )
$1
Surround selection in [ ]
$2
Surround selection in { }
$3
Surround selection in " "
$$ or $e
Surround selection in ' '
$q

Insert Mode

Insert ( )
$1
Insert [ ]
$2
Insert { }
$3
Insert ' '
$q
Insert " "
$e
Insert < >
$t
Date format: %d/%m/%y %H:%M:%S

Windows

Move to Upper Window
Ctrl-j
Move to Lower Window
Ctrl-k
Move to Lefter Window
Ctrl-h
Move to Righter Window
Ctrl-l

Buffers

Close Current Buffer
,bd
Close All Buffers
,ba
Go to Next Buffer
,l
Go to Previous Buffer
,h

Tabs

Open New Tab
,tn
Close All Other Tabs
,to
Close Current Tab
,tc
Move Current Tab
,tm
Go to Next Tab
,t,
Toggle b/w This Tab and Previous Tab
,t1
Open New Tab w/ Current Buffer's Path
,te
Switch CWD to Open Buffer's Directory
,cd

Editing

Go to First Non-blank Char
0
Move Line of Text Down
Alt-j
Move Line of Text Up
Alt-k

Spell Checking

Toggle Spell Checking
,ss
Move to Next Misspelled Word
,sn
Move to Previous Misspelled Word
,sp
Add Word to Dictionary
,sa
Suggest Spellings for Word
,s?

Misc

Remove ^M
,m
Open Buffer for Notes
,q
Open Markdown Buffer for Notes
,x
Toggle Paste Mode
,pp
Open File Under Cursor
gf
 

bufExp­lorer Plugin

Open bufExp­lorer
,o
Normal Open
\be
Force Horizontal Split Open
\bs
Force Vertical Split Open
\bv
Once the bufexp­lorer window is open you can use the normal movement keys (hjkl) to move around and then use <En­ter> or <Le­ft-­Mou­se-­Cli­ck> to select the buffer you would like to open.
If you would like to have the selected buffer opened in a new tab, simply press either <Sh­ift­-En­ter> or 't'.

Most Recently Used (MRU)

Open MRU
,f
Open File in Current Window
<En­ter>
Open File in New Window
o or <Sh­ift­-En­ter>
Open File in Read-only Mode
v
Open File in New Tab
t
Update File List
u
Close MRU
q or <Es­c>
You can open multiple files from the MRU window by specifying a count before pressing '<E­nte­r>' or 'v' or 'o' or 't'. You can also visually (using linewise visual mode) select multiple filenames and invoke the commands to open the files. Each selected file will be opened in a separate window or tab.

CTRL-P (Full Path Fuzzy _ Finder)

Open CTRL-P / Find File
Ctrl-f
Find Buffer/MRU
Ctrl-b
Update Results
<F5>
Filename Only
Ctrl-d
RegExp Mode
Ctrl-r
Go Down
Ctrl-j
Go Up
Ctrl-k
Open in New Tab
Ctrl-t
Open in New Tab (Vertical Split)
Ctrl-v
Open in New Tab (Horiz­ontal Split)
Ctrl-x
Select Next String in History
Ctrl-n
Select Previous String in History
Ctrl-p
Create New File (and parent direct­ories)
Ctrl-y
Mark/U­nmark Multiple Files
Ctrl-z
Open File
Ctrl-o
Run :help ctrlp-­map­pings or submit ? in CtrlP for more mapping help.

Submit two or more dots .. to go up the directory tree by one or multiple levels.

End the input string with a colon : followed by a command to execute it on the opening file(s): Use :25 to jump to line 25. Use :diffthis when opening multiple files to run :diffthis on the first 4 files.

Cope

Open Error List Window
,cc
Close Error List Window
:ccl
Go to Next Search Results
,n
Go to Previous Search Results
,p
Use :help cope to learn about cope
When searching in Ack.vim, display results in cope with ,cc
 

NERDTree (File Directory Tree)

Toggle NERDTree
,nn
NERDTree from Bookmark
,nb
NERDTree Find
,nf

SnipMate

Insert­/Na­vigate Snippet
<Ta­b>

VIM Multiple Cursors

Add Cursor
Ctrl-n
Remove Current Cursor (Go to Prev)
Ctrl-p
Remove Current Cursor (Go to Next)
Ctrl-x

surrou­nd.vim

Change Surrou­ndings
cs<­old­><n­ew>
Remove Surrou­ndings
ds<­old>
Revert Surrou­ndings
cst<ne­w>
Wrap Text Object
ysiw<n­ew>
Wrap Line
yss<ne­w>
Wrap (In Visual mode)
S<n­ew>

Vimroom (Distr­act­ion­-free Editing)

Embrace the Zen
,z
Abandon the Zen
,z!

Git Gutter

Toggle Git Gutter
,d

Ack (super fast grep for searching)

Open Ack
,g
:Ack [options] {pattern} [{dire­cto­ries}]
Use :Ack! if you don't want to jump to first result automa­tically

Must enclose pattern in ' ' if it has whites­pace.
Must escape # -> \\\#
? a quick summary of shortcuts, repeat to close

Vim-Co­mme­ntary

Comment out a line (takes a count)
gcc
Comment out target of a motion
gc
Uncomment adjacent commented lines
gcu
Repeat command to toggle

Vim-Ex­pan­d-R­egion

Expand Visual Selection
+
Shrink Visual Selection
-

Git Fugitive

View x in Repository
:Gedit x
Diff files against repository
:Gdiff
git status (- to add/reset changes, p to add/reset --patch)
:Gstatus
git commit
:Gcommit
git blame
:Gblame
git mv
:Gmove
git grep
:Ggrep
git log
:Glog
git checkout -- filename (on buffer)
:Gread
git add/ch­eckout
:Gwrite
Open file on Web (ex. github)
:Gbrowse
git <co­mma­nd>
:Git <co­mma­nd>
git <co­mma­nd> with open output in new file
:Git! <co­mma­nd>
Preface regular vim commands with G to do the git version.
Ex: :Gtabedit will open up the blob/t­ree­/co­mmi­t/tag in a new tab