Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3205901
  • 博文数量: 443
  • 博客积分: 11301
  • 博客等级: 上将
  • 技术积分: 5679
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-08 12:30
个人简介

欢迎加入IT云增值在线QQ交流群:342584734

文章分类

全部博文(443)

文章存档

2022年(1)

2021年(1)

2015年(2)

2014年(1)

2013年(1)

2012年(4)

2011年(19)

2010年(32)

2009年(2)

2008年(4)

2007年(31)

2006年(301)

2005年(42)

2004年(2)

分类:

2006-03-13 22:10:05

Command Meaning
vi File Name Open or Create File
vi Open New File To Be Named
vi -r File Name Recover Crashed File
view File Name Open File Read-Only
vipw Edit the /etc/passwd file, setting locks and doing appropriate processing.
There are three modes of operation: Command Mode
Insert Mode
Last Line Mode

Vi Commands Used To Edit Files Positioning The Cursor

Command Meaning
h Move left one character
j Move down one line
k Move up one line
l Move right one character
w Move right one word
W Move right one word (Past Punctuation)
b Move left one word
B Move left one word (Past Punctuation)
e Move to end of current word
Return Move down one line
Backspace Move left one character
H Move to top of screen
M Move to middle of screen
L Move to bottom on screen
Control-f Scroll forward one screen
Control-d Scroll forward one-half screen
Control-b Scroll backward one-half screen
G Go to last line of file
1G Go to first line of file
21G Go to 21st line of file

Appending Commands

Command Meaning
a Append text after cursor
A Append text at line end
i Insert text before cursor
I Insert text at beginning of line
o Insert line below cursor
O Insert line above cursor

Deleting Text

Command Meaning
x Delete Character at the cursor
X Delete character to the left of the cursor
dw Delete word (or part of word to right of cursor)
dd Delete line containing the cursor
D Delete part of line to right of cursor
dG Delete to end of file
d1G Delete from beginning of file to cursor
:5,10d Delete lines 5 through 10

Changing Text

Command Meaning
CW Change word (or part of word) to right of cursor
cc Change line
c Change from cursor to end of line
s Substitute string for characters from cursor forward
r Replace character at cursor with one other character
r Return Break line

Insert Mode

Command Meaning
J Join current line and line below
xp Transpose character at cursor and character to the right
~ Change case of letter (upper or lower )
u or :u Undo previous command
Undo all changes to cuurent line

Copying and Pasting

Command Meaning
y Yank or copy line
Y Yank or copy line
p Put yanked or deleted line below current
P Same as above

Saving Changes and Quitting

Command Meaning
:w Save changes (write buffer)
:w new file Write buffer to named file
:wq Save changes and quit Vi
:q! Quit without saving changes

Displaying and Hiding Line#

The SET command is used from last-line mode to control these options, as indicated in the table.
Command Meaning
:set nu Show line numbers
:set nonu Hide line numbers; setting is case sensitive
:set ic Searches should ignore case
:set noic Searches should be case sensitive
:set list Display invisible characters

Search and Replace

Command Meaning
/string Search for string
?string Search backward for string
n Find next occurrence of string in search direction
N Find previous occurrence of string in search direction
:%s/old/new/g Search and replace

Refresh the Screen and Including Files

Command Meaning
Control-1 Clear (refresh) scrambled screen
:r file name Insert (read) file after cursor
:34r file name Insert file after line 34

阅读(1093) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~