2013年5月9日 星期四

VIM 指令

VIM Command

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

move
[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
[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
> - increase indent
< - decrease indent
V - visual line mode
{n}> - increase {n} times indent
{n}< - decrease {n} times indent

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

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

replace
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
:tabe {file} - open {file} in new tab
gt - next tab

split view
: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
[CTRL]-w [-] - enlarge current horizontal window

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

commands
:n - go line number n
:set nonu - set no number
:set nu - set number on
:set paste - set paste mode

0 留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...