Skip to content
Hunter Wu edited this page Jan 16, 2019 · 1 revision

VIM hotkeys/commands

mode

KEY Desc
[ESC] normal mode
i insert mode
R replace mode
r replace one charactor
v visual mode
V visual line mode

move

KEY Desc
[h],[j],[k],[l] 左 下 上 右
gg go top of the file
G go bottom of the file
H go top of current screen
M go middle of current screen
L go last line of current screen
^ go beginning of the line
$ go end of the line
b backwards a word
w forward a word
f{c} find next char {c} in current line

edit

KEY Desc
[C] change to the end of the line
u undo
D delete from current char to the end
dw delete word from current char to the end
diw delete whole word
di> delete whole string inside <>
di) delete whole string inside ()
dt{c} delete to {c} in the line
Ctrl-r redo

indent

KEY Desc
> increase indent
< decrease indent
KEY Desc
V visual line mode
{n}> increase {n} times indent
{n}< decrease {n} times indent

paste

KEY Desc
v visual mode
y yank
p paste
KEY Desc
V visual line mode
KEY Desc
[Shift]-[Insert] Paste by PuTTY (in insert mode!)

find

KEY Desc
/{str}[ENTER] find {str}
n find next
[SHIFT]-n find previous

replace

KEY Desc
V visual line mode
:s/{find_str}/{replace_str} search and replace in current line
:%s/{find_str}/{replace_str} search and replace in all line

tab view

KEY Desc
:tabe {file} open {file} in new tab
gt next tab

split view

KEY Desc
:split {file} open {file} in horizontal split window
:vsplit {file} open {file} in vertical split window
[CTRL]-w [UP]/[DOWN]/[LEFT]/[RIGHT] focus another window
[CTRL]-w [|] enlarge current vertical window
[CTRL]-w {n} [|] set current vertical window to {n} column
[CTRL]-w [=] tile window
KEY Desc
[CTRL]-w [-] enlarge current horizontal window

others

KEY Desc
[CTRL]-p auto complete
[g][f] get file which filename is under cursor

commands

KEY Desc
:n go line number [n]
:set nonu set no number
:set nu set number on
:set paste set paste mode
:set ff=unix change file format to unix
:set fileencoding=utf-8 change file encoding to utf-8

make

yum install ncurses-devel -y
yum install libselinux-devel -y
hg clone https://vim.googlecode.com/hg/ vim
cd vim/src
./configure --with-features=big
make
Clone this wiki locally