Show Menu

Vim Configuration Cheat Sheet by

Vim Configuration - This is a description of the shortcuts I use the most in my vim configuration. Note that some of this shortcuts might have been remaped and might not work in a vanilla vim configuration unless the .vimrc is changed accordingly.
vim

Cursor Movements

h, j, k, l
left, up, down, right
Ctrl + U/D
move a bunch of lines up/down
w, W
jump forwards to the start of a word (can contain punctu­ation)
e, E
jump forwards to the end of a word (can contain punctu­ation)
b, B
jump backwards to the start of a word (can contain punctu­ation)
^
jump to first non-blank character of the line
0, $
jump to start/end of line
gg, G
go to first/last line of the file
5G
go to line 5

Insert­ing­/Ap­pending Text

i
insert before the cursor
I
insert at the beggining of the line
a
append text after cursor
A
append text at end of line
o
open a new line below current line
O
open a new line above current line

Marking text - Visual mode

v
start visual mode
V
linewise visual mode
Ctrl+v
start visual block mode
o
move to the other end of marked area
O
move to other corner of block
ab / aB
mark a block with () / {}
ib / iB
mark inner block with () / {}

Visual commands

Tab / S-Tab
shift text right / left
y
yank text (copy)
d
delete text
~
switch case

Editing

r
replace a single character
J
join line below to current one
cc
change entire line
cw
change to end of the word
c$
change to end of line
cib/B
change inside () / {}
cab/B
change () / {} whole block
s
delete character and substitute text
S
same as cc
u / Ctrl-r
undo / redo
.
repeat last command
S-Up / S-Down
move current line up / down

Cut and paste

yy
yank a line
yw
yank a word
y$
yank until end of line
p / P
paste after/­before cursor
dd
delete a line
dw
delete a word
D
delete to the end of the line
x
delete single character

Search and replace

/pattern
search pattern
?pattern
search pattern backwards
n / N
repeat search in same / opposite direction
<Le­ade­r>h
clear search highlight
:%s/ol­d/new/g
replace
:%s/ol­d/n­ew/gc
replace with confir­mations

Splits Management

Ctrl + i/j/k/l
move between splits
<Le­ade­r> +/-
increase / decrease current split vertical size
<Le­ade­r> </>
decrease / increase current split horizontal size
<Le­ade­r> <<
set horizontal size to 85 (ideal for 80 characters long lines)
<Le­ade­r> mm
maximize current buffer vertically
Ctrl+w =
equalize sizes
:sp file/path
open file in new horizontal split
:vsp file/path
open file in new vertical split

colon magic

, / ;
they input :, so we don't need to shift

Navigating the docs

:h/:help Name
open docs about Name
Ctrl+5
follow hyperlink
Ctrl+t
go back from hyperlink jump

Folds

zc/zo/za
close/­ope­n/t­oggle fold
zC/zO/zA
close/­ope­n/t­oggle fold on all levels
zR
set fold level to 0 (unfold everyt­hing)

Function Keys Mapping

F2
pastet­oggle
F3
NERDTree toggle
F4
Syntas­tic­Check
F5
Gundo Toogle
F9
Run script

Registers

"­{re­gname}y
yank into {regname} register. {regname} can be any letter.
"­{re­gname}p
paste from {regname} register.
0 register
only populated whenever you yank smth, not when you delete

Tabs

:tabedit {file}
open file in new tab
:tabfind {file}
find file in current path and open it in a new tab
:tabclose
close current tab
:tabclose {i}
close ith tab
:tabonly
close all tabs except current one
gt / gT
go to next / previous tab
{i}gt
go to ith tab
:tabm {i}
move current tab to ith position
:tabs
list all tabs and the files they include

Variable case manipu­lation

<Le­ade­r>kk
Change word under the cursor / visually selected variable from under_­sco­re_name to underS­cor­eName
 

UltiSnips

Ctrl-j
expand snippet
:UltiS­nip­sEdit
edit snipets

Tabular (visual mode edits only selection)

:Tabul­arize /pattern
use pattern to align text

CtrlP

Ctrl-p
enter fuzzy search mode
F5
reload cache
Ctrl-d
switch to search filenames mode
Ctrl-r
switch to regex mode
Ctrl-j / Ctrl-k
navigate search results
Ctrl-t
open result in new tab
Ctrl-x / Ctrl-v
open result in horizontal / vertical split
Ctrl-f
change mode ('line' for searching inside files, 'dir' for searching direct­ories)

NerdTree

:NERDTree [direc­tory]
open the directory tree
:NERDT­ree­Close
close it
[g]o
[leave cursor in tree] open files / direct­ories
[g]i
[leave cursor in tree] open file in horizontal split
[g]s
[leave cursor in tree] open file in vertical split
e
edit current directory
P
jump to root node
p
jump to parent node
I
toggle display hidden files
m
open menu (create files/­dirs, etc)

NERDCo­mmenter

<Le­ade­r>c­<Le­ade­r>
toggle comment
<Le­ade­r>cc
force comment
<Le­ade­r>cA
add a comment at the end of the line
<Le­ade­r>c$
comment from cursor position to the end of line

r-plugin

all shortcuts
<LL­>rf
start R
<LL­>ss
send selection to R (quiet)
<LL­>se
send selection to R (echo the code)
<LL­>sa
send selection to R (echo it) and then move down
<LL­>l
send line to R
<LL­>d
send line to R and then move down
<LL­>aa
send whole file to r
<LL­>ae
send whole file to R (echo it)
<LL­>ro
show/u­pdate object browser

vim-su­rround

cs{sym­bol­1}{­sym­bol2}
Change surrou­ndings of current word from {symbol1} to {symbol2}. Ej: cs"', from "­wor­d" to 'word'.
ds{symbol}
Remove surrou­nding {symbol} from current word. Eg. ds" "­wor­d" -> word
ys{tex­tob­jec­t}{­symbol}
Surround word selected by {texto­bject} with {symbol}. Eg. ysiw" on Hel|lo world = "­Hel­lo" world

vim-se­ssion - reopens tabs/b­uffer config­uration

:Sessi­onSave {name}
saves session
:Sessi­onOpen {name}
opens session (has tab comple­tion)
:Sessi­onClose
closes current opened session
:Delet­eSe­ssion {name}
deletes a saved session
vim --serv­ername {name}
opens session on vim opening

vim-mu­lti­ple­-cu­rsors

ctrl+n
place a cursor, repeat for placing another cursor to next occurrence of the word. In visual mode, place a cursor per line.
v
after using ctrl+n, insert commands to edit all cursors at the same time. Multil­etter commands such as dw or ciw don't work.

Closet­ag.vim

<Ct­rl>_
close last opened html/xml tag

django.vim - syntax htmldjango files

:setfi­letype htmldjango
change current file syntax to django

vim-ex­change - text exchange operator

cx{motion}
On the first use, define the first {motion} to exchange. On the second use, define the second {motion} and perform the exchange.
X
cx for visual mode
cxc
clear current marked motion
.
Repeats first exchange {motion}

Download the Vim Configuration Cheat Sheet

3 Pages
//media.cheatography.com/storage/thumb/skabed_vim-configuration.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

          VI Editor Cheat Sheet
          Vim NERDTree Cheat Sheet
          cVim Keyboard Shortcuts