Jun 27th, 2005
vi 小筆記
為貪方便以免看麻煩的man,再一次溫習了vi內一些常用的指令,總結了我認為有用的起來,以便自己速查。就如使用MS Word一樣,我們都只是用了它們1/10的功能也不到吧。
—
移動用 :
h = left
j = down
k = up
l = right$=end
0=home
CTRL-F = Page Up
CTRL-B = Page Down
CTRL-L = Refreshw,W=Word
b,B = Back Word
更改用:
i=insert
I=insert BOL
a=add
c=change
d=delete
o=start new linecw = change a word
cc = change whole line
r = change a characterdw = delete word
dd = delete a row
J = join two lines
Copy & Paste 用:
yw = copy word
yy = copy line
p = paste“f5yy = copy 5 lines into buffer “f”
“fp = paste buffer “f”
“fP = paste buffer “f” before cursorSearch & Replace:
/ = search mode
n = repeart search:1,30s/old/new/gc = replace global
其他:
. = repeat
u = undoline#G goto line
CTRL-G show status:e open other file
CTRL-^
歡迎說說你常用的指令啊!
我也來加2個:
1.整個file替換
:%s/old/new/g
2.last line
#G
謝謝你的建議!
Some VI tips here at “Efficient Editing with VIM”
http://jmcpherson.org/editing.html
Jacky, 你給的網頁很不錯啊!
[...] 記
六月 30th, 2005
VI
朋友的VI筆記,轉之亞當閒話 移動用 : h = left j = down k = up l = right $=end 0=home CTRL-F = Page [...]
VIM
我最常用的cmd
:sp - horizontal 分頁
:vert sp - vertical 分頁
:vert diffsp FILENAME - vertical diff with another file with name - FILENAME
:vi . - browse local dir
:set ic - search in case insensitive
* - search the cursor highlight word
* and then n - search next matched
* and then shit n - search backward matched
mm - local the cursor line on the middle page
mt - local the cursor line on the top
mb - local the cursor line on the bottom
ctrl u - page up
ctrl d - page down
:%s/a/b/gc - replace whole page from a with b globally and confirm every replace with you
:%s/\(hello\) \(world\)/\2 \1/gc - replace all “hello world” to “world hello” in the whole page
[...]
七月 23rd, 2005
VI 筆記(轉)
朋友的VI筆記,轉之亞當閒話 移動用 : h = left j = down k = up l = right $=end 0=home CTRL-F = Page [...]
哇! 阿當常用的已比我多了!! @_@
只是近日剛好翻看過舊筆記才會多記得數個 command,看來要每隔一段時間就看數個會較好
補充數個我會用的小 command:
:set nu 顯示 line numbers,不過會直接跳 line number 的人不會用吧?
x 刪除一個字母,不知道跟上文提及的 d 有何分別…
N 向上重覆搜尋
另,a 不是 add 而是 append 呢,在後面插字的,跟前面插字的 i 不同 ^_^
最後…也是近日才發現…vi 的 command 在其他地方也可用啊!
例如 more,less,man 等等,不過我也多數是用 / 及 n 而已 =P
[...] Thursday October 20, 2005 JST vi小笔记 via:亚当 移动用 : h = left j = down k = up l = right $=end 0=home CTRL-F = Page Up [...]
[...]
VI 筆記(轉)
朋友的VI筆記,轉之亞當閒話 移動用 : h = left j = down k = up l = right $=end 0=home CTRL-F = Page [...]