Show Menu
Cheatography

Juanjux's Vim Cheatsheet Cheat Sheet by

For custom mappings check: https://github.com/juanjux/My-Vim-dir/blob/master/.vimrc

Cursor movement and text motions

h/j/k/l
motion left/u­p/d­own­/right
f / F char
motion to char in current line
t / T char
motion 1 before­/after char in current line
w / B
motion to start of next / prev word
e / ge
motion to end of next / prev word
/[regexp]
search
0
motion to start of line
^ / รง
motion to start of line text
$
motion to end of line
[number] G / gg
go to line at [number]
gg
motion to start of buffer
G
motion to end of buffer
o (visual mode)
move cursor to start/end of selection
( / )
start / end of phrase
{ / }
start / end of paragraph
[{/]}/[(/])
motion to next / prev { }( )
<c-­o> / <c-­i>
navigate cursor location history
:goto [number]
go to byte at position number in buffer
* / #
search next / prev occurrence of word under cursor
<ld­r>ta
jump to tag user
<c-­j> / <c-­k>
pagedown / pageup user
<ld­r>e
shortcut jump to word user|p­lug­in:­eas­ymotion
<ld­r><­ldr>s [char]
shortcut jump to char bidire­ctional plugin­:ea­sym­otion
<ld­r><­ldr>e
shortcut jump to end of word forward plugin­:ea­sym­otion
<ld­r><­ldr>ge
shortcut jump to end of word backward plugin­:ea­sym­otion
[m / ]m
jump to prev / next function

Yank/Paste

register: "*
system clipboard (Windows)
register: "+
system clipboard (Linux)
register: "%
buffer name
register: *=
output of system()
:reg
list of registers
[register]y[motion]
yank (yy for current line)
p / P
paste at the / before current position
:pu / <ld­r>,
paste below current line user
gp
paste and move the cursor to the end
<ld­r>yy
show yankring user|p­lug­in:­yan­kring
<c-­p> (after pasting)
cycle between recent yanks plugin­:ya­nkring
<ld­r>V
select last pasted test user
<c-­rp> register
yank from register in insert mode

My Plugins

Pathogen
to manage plugins
Yankring
yank between different instances of Vim. Cycle when pasting
Project
simple project manage­ment. \C to create a new project, \R to update files
NERD_C­omm­enter
easily commen­t/u­nco­mment code
Matchparen
shows matching delimiter
Csapprox
use GVim colors­chemes in console Vim
Airline
awesome status bar
Tagbar
jumpable tag list
Vimwiki
personal Wiki
Syntastic
Validate syntax for several languages
EasyMotion
jump to any word/l­ine­/ch­aracter with few keystrokes
Unite
Fuzzy search for buffer­s/f­ile­s/etc
Matchit
improves VIm's % command to understant more delimiters
MatchT­agA­lways
highlight matching HTML tags
Tabular
align things
Emmet
Quickly edit HTML and move between tags
YouCom­pleteMe
excellent completion
VimCol­orS­chemes
lot of colors­chemes
Surround
operations on delimiters
Jdaddy
add a JSON text object
GTFO
shortcuts to open GUI file explorer or terminal in buffer CWD
Ack
:Ack search (but use ag instead of Ack!)
Repeat
the repeat operator (dot) will be able to repeat some plugin actions
LustyJ­uggler
Show buffers as a list, switch with a number
Rename
:Rename current buffer and the associated file
 

Operators: [repea­t]o­per­ato­r[m­otion]

d
delete, dd for line
c
change (delete and enter insert), cc for line
y
yank (yy for line)
gu / gU
to lowercase / uppercase
!
filter through external program
=
auto indent
gw
justify
> / <
indent / dedent
[repeat] [operator] [motion or text object]
Examples:
10dj (delete 10 lines down)
v3w (select 3 words ahead)
yiw (yank the inner-word object)
gwip (justify the inner-­par­agraph object)
3diw (delete the next 3 inner-­words)

Text edition (see also operators & motions)

i
enter insert mode
a
enter insert mode after cursor position (append)
x
delete char under cursor
r[newchar]
replace char under cursor
I
move to start of line and insert
A
move to end of line and append
D
delete from cursor to end of line
C
change from cursor to end of line
o / O
create new line and insert below / above cursor position
<ld­r>o / <ld­r>O
create new line above / below without going to insert mode
:tab /[char]/l1
tabularize from [char] left align 1 space plugin­:ta­bul­arize
ys[motion] [delim­iter]
surround motion­/object with delimiter plugin­:su­rround
S[visual selection] [delim­iter]
surround visual selection with delimiter
cs[delim­iter] [newdelim]
change surrou­nding delimiter for newdelim plugin­:su­rround
ds[delim­iter]
delete surrou­nding delimiter plugin­:su­rround
<ld­r> c<s­pac­e>
comment / uncomment
J
join lines
[operator] <ld­r>e
shortcut operate by lines with plugin­:ea­sym­otion
<c-­w> (insert mode)
delete one word back

Ex Comman­dline

range: %
full buffer
range: . (dot)
current line
range: $
last line
range: +-N
+-N lines from current position
selector: g
global command (selects lines matching regexp)
selector: v
inverse (select lines NOT matching regexp)
operator: d
delete
operator: ![program]
replaces with output from external program
operator: s/old/new
replaces old with new
operator: y
yank
operator: normal [commands]
run commands over every line in the range or selection
operator: put [register]
put the register content below the current line
The format is one of:
:[rang­e][­sel­ect­or]­/[r­ege­xp]­/[o­per­ation]
:[rang­e][­ope­ration]
:[oper­ation]
Example:
:20,30­g/F­IXME/d => delete lines from 20 to 30 with the string FIXME
:.,$v/­DON­TDE­LETE/d => delete lines without the string DONTDELETE from current position to end of buffer.
:%s/ol­d/new => replace all instances of old with new
:.!ls => insert output of ls replacing current line

Emmet plugin for HTML

<c-­y> (insert mode)
expand HTML abbrev­iature like: Div#pa­ge>­div.lo­go+­ul>li5*>a
<c-­y> , (visual mode)
wrap selection inside tag (asks for tag)
<c-­y> n/N
jump to next / prev editable point
<c-­y> k
remove current tag
<c-­y> /
comment tag
<c-­y> a
converts URL to <A> tag
<c-­y> A
converts URL to <A> tag autolo­ading site descri­ption
<c-­y> c
prettify code with CSS classes by type
<c-­y> d
sleect tag surrou­nding the cursor
<c-­y> D
select next inside tag or next tag
<c-­y> i
update image size
<c-­y> j
join separate block: <p>­</p> โ‡’ <p/>
<c-­y> ,
with "­lor­em" in insert mode, writes lorem ipsum

Spellcheck

<ld­r>ss
spanish spell check user
<ld­r>se
english spell check
<ld­r>sn
disable spell check
z=
sugges­tions for word under cursor
]s / [s
next / prev misspelled word
zg
add word to user dictionary
 

Text Objects i/a[ob­ject]

l
char
w/W
word / WORD
s
sentence
(/) or b
(block)
{/} or B
{block}
j
JSON block, use gw to prettify plugin­:jdaddy
p
paragraph

Windows / Buffers / Tabs / Splits

:w
save buffer
:q/:x
exit / save and exit
:e [path]
open file at path, use "." for netrw browser
:bd
delete buffer (doesn't delete file)
<ld­r>v
create vertical split and jump to it user
<ld­r>tn
new tab user
<c-­h> / <c-­l>
move to left / right tab user
[number]gt
go to tab [number]
:sp
create horizontal split
<ld­r>cv
close current split user
<ld­r>bt
open all buffers in tabs user
:tabm [pos]
move tab to pos (can be +/-pos)
<sp­ace­><s­pac­e>
Unite buffer­s/MRU user|p­lug­in:­unite
<sp­ace>b
Unite buffers plugin­:unite
<sp­ace>m
Unite most recently used plugin­:unite
<sp­ace>f
Unite search files recurs­ively plugin­:unite
<c-­w>T
Convert split to tab
<c-­w>r
Rotate split positions
:tabo
close all tabs except current
:w!!
save buffer as root with sudo user

Marks

m[mark]
create mark [mark]
'[mark]
jump to start of line with [mark]
`[mark] / ยก
jump to [mark]
mark: 0 (zero)
last file edited
mark: '
before last jump
mark: ,
last edition point

Undo / Redo

u
undo
<c-­r>
redo
:earlier [time spec]
s:second / m:minute / h:hour / d:days
:later [time spec]
s:second / m:minute / h:hour / d:days

Misc

<c-­o> (insert mode)
run a command in insert mode
<ld­r>cdt
update D tags user
<ld­r>ct
clear trailing whitespace user
<ld­r>sv
reload .vimrc user
<ld­r>rr
systax on and off (to reset colors) user
za / zA
toggle fold / class level
gof
open graphical file browser in buffer cwd plugin­:gtfo
got
open command terminal in buffer cwd plugin­:gtfo
<ld­r><sp­ace>
clear search result highlights user
<ld­r>gs
save vim session user
<ld­r>css
load vim session user
v / V
enter visual mode / by line
<c-­v>
visual block selection (I to insert before, A to append after)
<ld­r>tb
open tag bar split user|p­lug­in:­tagbar
<ld­r>P
open project split user|p­lug­in:­project
<ld­r>sy
syntactic check with syntactic user|p­lug­in:­syn­tactic
:Ack
search with Ack/ag
:windo diffthis
mark split for windiff (do twice)
. (dot)
repeat last change
:sort [selec­tion]
sorts the selection
:Rename
rename current buffer and file plugin­:rename
<ld­r>lj
show buffer list, switch with a number plugin­:lu­sty­juggler
@:
repeat last ex mode command
[Bash Shell] set -o vi
put bash comman­dline in vi mode
[Bash shell in vi mode] <es­c>v
edit shell command in Vim

Tricks

xp in normal mode to exchange two chars
ddp to exchange two lines (or lower the current one one down)
In the Bash shell, use set -o vi to enable Vi mode. Then use <es­c> and edit your command like in Vi or use v to edit your command line in Vim
           
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          VI Editor Cheat Sheet
          Vim NERDTree Cheat Sheet