Miles' Blog

天涯何處無幹話,何必要講實務話

Vim

Vim 是 Vi 的進階版

Cheat Sheet

Mode

Vim 模式

Mode Description How to Enter
Normal Mode 正常模式,平常進來也是這個模式 其他模式按 Esc 或 Ctrl + [
Insert Mode 編輯模式,也就是平常要輸入的時候會使用的模式 Normal Mode 按 i
Replace Mode 取代模式 Normal Mode 按 R
Visual Mode 視覺標記模式,就很像平常用滑鼠選取文字一樣 Normal Mode 按 v
Visual Line Mode 視覺整行標記模式,同 Visual Mode,差別它是以行為單位 Normal Mode 按 V

Install

apt-get update && apt-get install vim -y

Command

Cursor movement

Key Action
e jump to the end of a word
0 jump to the start of the line
^ jump to the start word of the line
$ jump to the end of the line
{ jump to previous para`graph
} jump to next paragraph
gg go to the first line of the document
G go to the last line of the document

Searching

/pattern     search forward for pattern
?pattern     search backward
n            repeat forward search
N            repeat backward

Cut and paste

yy  copy a line
p   paste the clipboard after cursor
x   delete character
D   delete to the end of the line
dd  delete a line

Delete all lines

gg then dG

Edit

u       undo
Ctrl+r  redo

Insert mode

i   insert before the cursor
A   insert at the end of the line
o   append a new line below the current line    

Visual mode

v   start visual mode
V   start linewise visual mode

>   shift text right
<   shift text left

References

VIM as IDE

.vimrc 設定:

參考網頁:

Tree 外掛

Vundle:

0%