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.
|
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 punctuation)
|
|
e, E
|
jump forwards to the end of a word (can contain punctuation)
|
|
b, B
|
jump backwards to the start of a word (can contain punctuation)
|
|
^
|
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
|
|
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
|
|
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 () / {}
|
|
Tab / S-Tab
|
shift text right / left
|
|
y
|
yank text (copy)
|
|
d
|
delete text
|
|
~
|
switch case
|
|
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
|
|
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
|
|
/pattern
|
search pattern
|
|
?pattern
|
search pattern backwards
|
|
n / N
|
repeat search in same / opposite direction
|
|
<Leader>h
|
clear search highlight
|
|
:%s/old/new/g
|
replace
|
|
:%s/old/new/gc
|
replace with confirmations
|
|
Ctrl + i/j/k/l
|
move between splits
|
|
<Leader> +/-
|
increase / decrease current split vertical size
|
|
<Leader> </>
|
decrease / increase current split horizontal size
|
|
<Leader> <<
|
set horizontal size to 85 (ideal for 80 characters long lines)
|
|
<Leader> 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
|
|
, / ;
|
they input :, so we don't need to shift
|
|
:h/:help Name
|
open docs about Name
|
|
Ctrl+5
|
follow hyperlink
|
|
Ctrl+t
|
go back from hyperlink jump
|
|
zc/zo/za
|
close/open/toggle fold
|
|
zC/zO/zA
|
close/open/toggle fold on all levels
|
|
zR
|
set fold level to 0 (unfold everything)
|
|
F2
|
pastetoggle
|
|
F3
|
NERDTree toggle
|
|
F4
|
SyntasticCheck
|
|
F5
|
Gundo Toogle
|
|
F9
|
Run script
|
|
: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
|
|
<Leader>kk
|
Change word under the cursor / visually selected variable from under_score_name to underScoreName
|
|
"{regname}y
|
yank into {regname} register. {regname} can be any letter.
|
|
"{regname}p
|
paste from {regname} register.
|
|
0 register
|
only populated whenever you yank smth, not when you delete
|
|
Ctrl-j
|
expand snippet
|
|
:UltiSnipsEdit
|
edit snipets
|
|
:Tabularize /pattern
|
use pattern to align text
|
|
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 directories)
|
|
:NERDTree [directory]
|
open the directory tree
|
|
:NERDTreeClose
|
close it
|
|
[g]o
|
[leave cursor in tree] open files / directories
|
|
[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)
|
|
<Leader>c<Leader>
|
toggle comment
|
|
<Leader>cc
|
force comment
|
|
<Leader>cA
|
add a comment at the end of the line
|
|
<Leader>c$
|
comment from cursor position to the end of line
|
|
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/update object browser
|
|
:SessionSave {name}
|
saves session
|
|
:SessionOpen {name}
|
opens session (has tab completion)
|
|
:SessionClose
|
closes current opened session
|
|
:DeleteSession {name}
|
deletes a saved session
|
|
vim --servername {name}
|
opens session on vim opening
|
|
<Ctrl>_
|
close last opened html/xml tag
|
|
:setfiletype htmldjango
|
change current file syntax to django
|
|
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}
|
|
cs{symbol1}{symbol2}
|
Change surroundings of current word from {symbol1} to {symbol2}. Ej: cs"', from "word" to 'word'.
|
|
ds{symbol}
|
Remove surrounding {symbol} from current word. Eg. ds" "word" -> word
|
|
ys{textobject}{symbol}
|
Surround word selected by {textobject} with {symbol}. Eg. ysiw" on Hel|lo world = "Hello" world
|
|
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. Multiletter commands such as dw or ciw don't work.
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.