vi
时间:2010-05-28 来源:yingmeie
1, move: h, j, k, l,
h left, j next, k up, l right 2, page down: ctl + f, page up: ctl + b 3, copy n lines from soruce to destination, source location: nyy, destination: p.
If only manipulate one line, the n can be omitted. 4, move n lines from soruce to destination, source location: ndd, destination: p.
If only manipulate one line, the n can be omitted. 5, copy one word from source to destination: source location: yw, destination: p.
The p command will put the word after the current cursor. 6, copy n characters from source to destination, source location: nyl/h, destination: p.
l/h locate n ones from the cursor to right or left. 7, print number: :set number 8, search: /word 9, replace: :begin, end s/old/new/g.
Example: :1, $ s/vi/vim/g 10, jump to the No. line, first print: No., then print: shift + g 11, move to the end of line: $, to the begin of line: ^ 12, move to the end of file: :$ 13, move to the last cursor location, first at the cursor location: ma(mark the location as name a),
move the cursor to the other location, if want to move to 'a' again: :'a 14, vi modify many files, vi a.file b.file, change the file: :n(next), :N(previous) 15, vi modify many files as split windows, vi -o a.file b.file, change the files: ctl + w(twice) 16, vi open one file, then want to open the other: :e file, change the file: :e# 17, vi open one file, then want to open the other as split windows: :split file, change the file: ctl + w(twice) 18, copy one area to the other location, at the begin line of area: ma, at the end line of area: mb, at the new
location: mc, then: :'a, 'b copy/move 'c 19, copy n lines to another file, at the first file: "anyy, at the destination file: "ap.
The first and destination file must be open in one vi task.
This copy can also be completed without the "a(mark), just yy and p
相关阅读 更多 +