VI reference

Read a File Using vi
 vi filename Edit file
 vi + filename Start at last line
 vi +n filename Start at line n
 vi -R filename Read only mode

Word Commands
 w   Next word
 b   Back word
 e   End of word
 (   Beginning of sentence
 )   End of sentence
 }   Beginning of paragraph
 {   End of paragraph

Basic Cursor movement
 k   up
 h l  left right
 j   down

Arrow keys may also be used
 CR  Down one line to first non-blank
 0  Beginning of line
 $  End of line

Screen Control -- NOTE: CNTL followed by a letter signifies a control-key sequence.
 CNTL-b   Scroll back a whole page
 CNTL-f   Scroll forward a whole page
 CNTL-u   Scroll up a half page
 CNTL-d   Scroll down a half page
 CNTL-e   Scroll up one line
 CNTL-y   Scroll down one line
 CNTL-l   Refresh current screen (May be terminal dependent)
 CNTL-g   Display line number of current line
 :set number  Number lines
 :set nonumber  Remove line numbers
 
Inserting Text -- Commands are exited with the escape (ESC) character.
 i   Insert before cursor
 I   Insert at beginning of line
 a   Append after cursor
 A   Append at end of line
 o   Open lines after current line
 O   Open lines before current line
Changing Text -- Commands are exited with the escape (ESC) character.
 C   Change from cursor to end of line
 s   Substitute character
 S   Substitute line
 cw   Change word
 r   Replaces the current (no ESC necessary)
 R   Replaces from current cursor position to end of line; only changes typed-over characters
 
Delete Commands
 x   Delete character
 dw   Delete word
 dd   Delete line
 D   Delete from cursor to end of line
 d   Delete from cursor to beginning of line
 u   Undo command
 U   Restore entire line
 
Search Commands
 /string   Search for string below the current line
 ?string   Reverse search for string
 n     Repeat last search

Control Commands
:w                     Write file
:w filename            Writes to file filename
:w! filename           Overwrites the file filename
:x,y w filename        Write lines x through y to file filename
:wq                    Write file and quit
ZZ       Write file and quit
:q       Quit
:q!      Quit and no changes are saved
:num      Go to line number
:!command     Execute command
:!!command     Execute command and put output on current line
:e filename    edits filename
:r filename    places a copy of filename below current line
:r !command    Execute command and put output below current line

Copy Commands
y   Yanks current character
#y   Yanks # characters from current character
yw   Yanks current word
#yw  Yanks # words from current word
yy   Yanks current line
#yy  Yanks # lines from current line
:x,y  Yanks lines x thru y
p   Places most recently yanked characters,words or lines after current character orline
P   Places most recently yanked characters,words or lines before current character/line
:x mz  Moves line x below line z
:x,y mz Moves lines x through y below line z
:xt z  Copies line x below line z
:x,yt z Copies lines x through y below line z
J   Joins the current line and the line below it
#J   Joins # lines, beginning with the currentline

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值