Vi 速查手册(摘自wks.uts.ohio-state.edu)

原文: http://wks.uts.ohio-state.edu/unix_course/intro-134.html ( http://wks.uts.ohio-state.edu/unix_course/)
作者:wks.uts.ohio-state.edu
[Next] [Previous] [Up] [Top] [Contents]

CHAPTER 10 Editors

10.3 vi Quick Reference Guide


All commands in vi are preceded by pressing the escape key. Each time a different command is to be entered, the escape key needs to be used. Except where indicated, vi is case sensitive.
Cursor Movement Commands:
(n) indicates a number, and is optional
(n)h left (n) space(s)
(n)j down (n) space(s)
(n)k up (n) space(s)
(n)l right (n) space(s)
(The arrow keys usually work also)
^F forward one screen
^B back one screen
^D down half screen
^U up half screen
(^ indicates control key; case does not matter)
H beginning of top line of screen
M beginning of middle line of screen
L beginning of last line of screen
G beginning of last line of file
(n)G move to beginning of line (n)
0 (zero) beginning of line
$ end of line
(n)w forward (n) word(s)
(n)b back (n) word(s)
e end of word
     
     
Inserting Text:
i insert text before the cursor
a append text after the cursor (does not overwrite other text)
I insert text at the beginning of the line
A append text to the end of the line
r replace the character under the cursor with the next character typed
R Overwrite characters until the end of the line (or until escape is pressed to change command)
o (alpha o) open new line after the current line to type text
O (alpha O) open new line before the current line to type text
Deleting Text:
dd deletes current line
(n)dd deletes (n) line(s)
(n)dw deletes (n) word(s)
D deletes from cursor to end of line
x deletes current character
(n)x deletes (n) character(s)
X deletes previous character
Change Commands:
(n)cc changes (n) characters on line(s) until end of the line (or until escape is pressed)
cw changes characters of word until end of the word (or until escape is pressed)
(n)cw changes characters of the next (n) words
c$ changes text to the end of the line
ct(x) changes text to the letter (x)
C changes remaining text on the current line (until stopped by escape key)
~ changes the case of the current character
J joins the current line and the next line
u undo the last command just done on this line
. repeats last change
s substitutes text for current character
S substitutes text for current line
:s substitutes new word(s) for old
:<line nos effected> s/old/new/g
& repeats last substitution (:s) command.
(n)yy yanks (n) lines to buffer
y(n)w yanks (n) words to buffer
p puts yanked or deleted text after cursor
P puts yanked or deleted text before cursor
File Manipulation:
:w (file) writes changes to file (default is current file)
:wq   writes changes to current file and quits edit session
:w! (file) overwrites file (default is current file)
:q   quits edit session w/no changes made
:q!   quits edit session and discards changes
:n   edits next file in argument list
:f (name) changes name of current file to (name)
:r (file) reads contents of file into current edit at the current cursor position (insert a file)
:!(command) shell escape
:r!(command) inserts result of shell command at cursor position
ZZ write changes to current file and exit


Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值