linux文件编辑vi命令详解Linux file editor VI command detailedWord格式文档下载.docx
《linux文件编辑vi命令详解Linux file editor VI command detailedWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《linux文件编辑vi命令详解Linux file editor VI command detailedWord格式文档下载.docx(10页珍藏版)》请在冰豆网上搜索。
2,thebasicoperationofVI
A)enterVI
AfterthesystempromptsymbolentersVIandfilename,entertheVIfullscreeneditscreen:
$VImyfile
ButonethingtopayspecialattentiontoisthatafteryouenterVI,youareinthemode(command),andyouhavetoswitchtoInsertmodetoenterthetext.ThefirstuseofVIpeoplewillwanttousethearrowkeystomovethecursor,thecomputerhasbeencalledbleep,hismad,soafterenteringtheVI,thefirstnottomoveinto"
insertmode(Insertmode)"
!
B)switchtoinsertmode(Insertmode)toeditthefile
Underthecommandlinemode(commandmode),presstheletter"
I"
toenter"
Insertmode"
thenyoucanstarttyping.
C)Insertswitching
Youarecurrentlyinthe"
mode,andyoucanonlyenterthetextallthetime,ifyoufindthewrongword!
Ifyouwanttomovebackwiththecursorkeys,deletethewordfirst,presstheESCkey,gotocommandlinemode(commandmode),andthendeletethetext.
D)quitVIandsavethefile
Inthecommandlinemode(commandmode),click"
:
"
thecolonkeyenters"
Lastlinemode"
forexample:
Wfilename(enter"
Wfilename"
)savethearticleasthespecifiedfilenamefilename.)
WQ(enterWQ,saveandexitVI)
q!
(enterQ,donotsave,forceVI)
3,commandlinemode(commandmode)functionkeys
1)insertmode
Press"
toswitchtoinsertmode"
insertmode"
press"
toentertheinsertmode,thenstartthefilefromthecurrentpositionofthecursor;
Whenyoupressatoentertheinsertmode,enterthetextfromthenextpositioninthecurrentcursor;
Accordingtothe"
O"
intotheinsertmode,istoinsertanewline,startingfromtheinputtext.
2)switchfrominsertmodetocommandlinemode
Pressthe"
ESC"
key.
3)movecursor
VIcanmovedirectlyupanddownwiththecursoronthekeyboard,buttheregularVIuseslowercaseEnglishletters"
H"
"
J"
K"
L"
respectively,tocontrolthecursor,left,bottom,topandright.
Ctrl"
+"
B"
movethescreentotheback.
F"
movethescreentothefront.
U"
thescreenmovesback"
half"
.
d"
movethescreentothefront"
halfpage"
Pressthenumber"
0"
movetothebeginningofthearticle.
G"
movetotheendofthearticle.
$"
movetocursor"
attheendoftheline"
^"
themovetocursor"
W"
thecursorjumpstothebeginningofthenextword
e"
thecursortojumptothenextwordsuffix
PressBtoreturnthecursortothebeginningoftheword
#l"
thecursortothelineofthe#position,suchas:
5L,56l.
4)deletetext
X"
eachtimethecursorisdeleted,acharacterisremovedfromthecursor'
slocation.
#x"
forexample,"
6x"
meansthe6charactersofthebackofthecursorwherethecursorisdeleted.
uppercaseX,andeachtimethecursorisdeleted,acharacterinfrontofthecursorisdeleted.
#X"
20X"
meansthe20charactersinfrontofthecursorwherethecursorisdeleted.
DD"
deletesthecursor'
sline.
#dd"
deleterowsfromthecursorto#
5)copy
YW"
thecursortowherethesuffixcharactersarecopiedtothebuffer.
#yw"
copy#wordstothebuffer
YY"
copythecursorlinetothebuffer.
#yy"
6yy"
meanscopying6linesoftextfromthelineinwhichthecursorislocated.
P"
putthecharactersinthebuffertothecursor'
slocation.Note:
allreplicationcommandsassociatedwith"
Y"
mustworkwith"
tocompletecop