|
yiw
|
yank (inner) word
|
|
viwp
|
replace word with yanked
|
|
viw"0p
|
replace another word with yanked
|
|
ctrl-r +
|
paste from OS paste board
|
|
H / M / L
|
move to top/middle/bottom of screen
|
|
ctrl-d/u
|
move half screen down/up
|
|
ctrl-t/d
|
Indent current line forward/back in insert mode
|
|
</>
|
Indent block in visual mode (repeat with .)
|
|
:set shiftwidth=4
|
Set indent to 4
|
|
:set tabstop=8
|
Set tab to 8
|
|
:set (no)expandtab
|
Convert (spaces)tabs
|
|
:set pastetoggle
|
change to paste mode
|
|
:set expandtab + set ts=4 + :%retab!
|
Convert tabs to four spaces in entire file
|
|
:set noexpandtab + set ts=4 + :%retab!
|
Convert spaces to tabs in entire file
|
|
zM/zR
|
fold/unfold buffer
|
|
zc/zo
|
fold/unfold paragraph
|
|
zC/zO
|
fold/unfold all levels in paragraph
|
|
:set foldmethod=indent
|
fold by indentation
|
|
:set foldmethod=syntax
|
fold by syntax
|
|
n Ctrl-<>
|
dec/inc window width by n
|
|
n Ctrl-+/-
|
inc/dec window height by n
|
|
Ctrl-W=
|
make windows equal size
|
|
Ctrl-w s/v
|
split window horizontally/vertically
|
|
Ctrl-w c
|
close window
|
|
Ctrl-w w
|
move to next window
|
|
Ctrl-w hjkl
|
move to hjkl window
|
|
:mksession <file>
|
Save session
|
|
:source <file> or vim -S <file>
|
Open session
|
|
vim --remote
|
Open file in existing window
|
|
vim --sessionname <name>
|
Create new session <name>
|
|
vim --servername <name>
|
Open file in existing session <name>
|
|
ctrl-]
|
jump to definition
|
|
ctrl-w }
|
show preview
|
|
ma
|
set local mark a
|
|
mA
|
set global mark A
|
|
'a
|
jump to line with mark a
|
|
`a
|
jump to position with mark a
|
|
:%!command
|
filter buffer through command
|
|
:w !sudo tee %
|
save file even if write protected
|
|
:%s//<bar>/g
|
replace every occurence of last search term
with <bar> |
|
:%s/<c-rw>/<foo>/g
|
replace every occurence under cursor with <foo>
|
|
:g/pattern/d
|
delete lines containing pattern
|
|
:v/pattern/d
|
delete lines not containing pattern
|
|
:n,m ! cmd
|
filter lines n to m through shell cmd
|
|
:new|r ! cmd
|
run cmd, put output to new window
|
|
:set wrap linebreak nolist
|
set soft wrap
|
|
:set list
|
show spaces, tabs, newlines
|
|
:nohlsearch
|
clear search highlights
|
|
:%!nl -ba
|
Add line numbers (different from :set number)
|
|
,cc
|
comment code
|
|
,co
|
uncomment code
|
|
,c / ,v
|
copy/paste from persistent buffer
|
|
,a
|
Search for pattern with ack-grep
|
|
,A
|
Search word under cursor with ack-grep
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.