Show Menu

Juanjux's Vim Cheatsheet Cheat Sheet by

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

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
/[re­gexp]
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­|pl­ugi­n:e­asy­mot­ion
<ld­r><­ldr­>s [char]
shortcut jump to char bidire­ctional plug­in:­eas­ymo­tion
<ld­r><­ldr­>e
shortcut jump to end of word forward plug­in:­eas­ymo­tion
<ld­r><­ldr­>ge
shortcut jump to end of word backward plug­in:­eas­ymo­tion
[m / ]m
jump to prev / next function

Yank/Paste

regis­ter: "*
system clipboard (Windows)
regis­ter: "+
system clipboard (Linux)
regis­ter: "%
buffer name
regis­ter: *=
output of system()
:reg
list of registers
[regis­ter­]­y­[mo­tion]
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­|pl­ugi­n:y­ank­ring
<c-­p> (after pasting)
cycle between recent yanks plug­in:­yan­kring
<ld­r>V
select last pasted test user
<c-­rp> register
yank from register in insert mode

My Plugins

Path­ogen
to manage plugins
Yank­ring
yank between different instances of Vim. Cycle when pasting
Proj­ect
simple project manage­ment. \C to create a new project, \R to update files
NERD­_Co­mme­nter
easily commen­t/u­nco­mment code
Matc­hpa­ren
shows matching delimiter
Csap­prox
use GVim colors­chemes in console Vim
Airl­ine
awesome status bar
Tagbar
jumpable tag list
Vimw­iki
personal Wiki
Synt­astic
Validate syntax for several languages
Easy­Mot­ion
jump to any word/l­ine­/ch­aracter with few keystrokes
Unite
Fuzzy search for buffer­s/f­ile­s/etc
Matc­hit
improves VIm's % command to understant more delimiters
Matc­hTa­gAl­ways
highlight matching HTML tags
Tabu­lar
align things
Emmet
Quickly edit HTML and move between tags
YouC­omp­let­eMe
excellent completion
VimC­olo­rSc­hemes
lot of colors­chemes
Surr­ound
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
Lust­yJu­ggler
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­[ne­wchar]
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 /[cha­r]/l1
tabularize from [char] left align 1 space plug­in:­tab­ula­rize
ys­[m­otion] [deli­miter]
surround motion­/object with delimiter plug­in:­sur­round
S[­visual selection] [deli­miter]
surround visual selection with delimiter
cs­[d­eli­miter] [newd­elim]
change surrou­nding delimiter for newdelim plug­in:­sur­round
ds­[d­eli­miter]
delete surrou­nding delim­iter plug­in:­sur­round
<ld­r> c<sp­ace­>
comment / uncomment
J
join lines
[oper­ator] <ld­r>e
shortcut operate by lines with plug­in:­eas­ymo­tion
<­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
selec­tor: g
global command (selects lines matching regexp)
selec­tor: v
inverse (select lines NOT matching regexp)
opera­tor: d
delete
opera­tor: !­[pr­ogram]
replaces with output from external program
opera­tor: sol­dnew
replaces old with new
opera­tor: y
yank
opera­tor: normal [comm­ands]
run commands over every line in the range or selection
opera­tor: put [regi­ster]
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#p­age­>di­v.l­ogo­+ul­>li­5*­>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
wW
word / WORD
s
sentence
() or b
(block)
{} or B
{block}
j
JSON block, use gw to prettify plug­in:­jda­ddy
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
[numb­er]­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)
<­spa­ce>­<sp­ace­>
Unite buffer­s/MRU user­|pl­ugi­n:u­nite
<sp­ace­>b
Unite buffers plug­in:­unite
<sp­ace­>m
Unite most recently used plug­in:­unite
<sp­ace­>f
Unite search files recurs­ively plug­in:­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
:ear­lier [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 plug­in:­gtfo
got
open command terminal in buffer cwd plug­in:­gtfo
<ld­r>­<s­pac­e>
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­|pl­ugi­n:t­agbar
<ld­r>P
open project split user­|pl­ugi­n:p­roj­ect
<ld­r>­sy
syntactic check with syntactic user­|pl­ugi­n:s­ynt­actic
:Ack
search with Ack/ag
:windo diffthis
mark split for windiff (do twice)
. (dot)
repeat last change
:sort [sel­ect­ion]
sorts the selection
:Ren­ame
rename current buffer and file plug­in:­ren­ame
<ld­r>­lj
show buffer list, switch with a number plug­in:­lus­tyj­ugg­ler
@:
repeat last ex mode command
[Bash Shell] set -o vi
put bash comman­dline in vi mode
[Bash shell in vi mode] <­esc­>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

Download the Juanjux's Vim Cheatsheet Cheat Sheet

4 Pages
//media.cheatography.com/storage/thumb/juanjux_juanjux-s-vim-cheatsheet.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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