0% found this document useful (0 votes)
65 views5 pages

VI File VI +50 File VI +/pattern File

The document summarizes the vi and ex text editors in UNIX. It describes vi's two modes, command mode and insert mode. Common vi commands are described such as d to delete, y to yank/copy, and motions. Ex commands are also outlined including :wq to write and quit, :q! to quit without saving, and address ranges. Sed is introduced as a non-interactive stream editor used to perform editing actions on files using scripts.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views5 pages

VI File VI +50 File VI +/pattern File

The document summarizes the vi and ex text editors in UNIX. It describes vi's two modes, command mode and insert mode. Common vi commands are described such as d to delete, y to yank/copy, and motions. Ex commands are also outlined including :wq to write and quit, :q! to quit without saving, and address ranges. Sed is introduced as a non-interactive stream editor used to perform editing actions on files using scripts.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

UNIXEDITORS viEDITOR CommandLineSyntax: StartingtheSection: vifile vi+50file vi+/patternfile Endingthesection: :wq :q! viModes: Ithas2modes:commandmodeandinsertmode(editfile). SyntaxoftheCommands: [n]operator[m]motion Thebasiceditoperatorsare: ddelete yyank(copy) Ifthecurrentlineistheobjectofoperation,themotionisthesameastheoperator,thenuseddandyy. Otherwise,itwillworkliked}forexample,whereyoudeleteuntilthenextparagraph.Thenandmare thenumberoftimestoperformetheoperation,so5yymeanstocopy5lines. StatuslineCommands: Thesecommandsarenotechoedonthescreenasyouinputthem.Thestatusline(inthebottomofthe screen)isusedforeditingthem. /Seachforwardforapattern ?Searchbackwardforapattern :Invokeanexcommand 1 Savethemodificationsandquit. Quitwithoutsaving. Openthefileforediting Openthefileatline50forediting Openfile(wherepatternappearsthefirsttime)forediting.

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

viCommands: Command /pattern n % fx Fx :num =% i dd d$ d} p u . yy y$ paste undo repeat copy delete search Action Repeatprevioussearch. Findmatchofcurrentparenthesis,braceorbracket. Movecursorforwardtoletterxoncurrentline. Movecursorbackwardtoletterxoncurrentline. linenumber Movetolinenumber. aligntext insert Positionthecursorinthelineofanopeningstatementcurlybracket,then pressESCand=%toalignthelines. Insertbeforecursor. Deletecurrentline. Deletefromcurrentpositiontoendofline. Deleteuptonextparagraph. Insertlastdeletedoryankedtextafterthecursor. Undolastchange. Repeatlastchange. Copycurrentline. Copyrestofline. exEDITOR Syntaxofexcommands: :[address]command[options] Address: Especifytheaddressusingarangeoflines:(x,y). Address 1,$(or%) Alllinesinthefile. Meaning Description Searchforwardforpattern.EndwithENTER.

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

Address x,y num 0 . $ /pattern/ Options: Option ! count file Commands: Command Linesxtoy. Absolutelinenumber. Topofline. Currentline. Lastline. Forwardtolinematchingpattern.

Meaning

Meaning Variantforofthecommand,mustcomeimmediatelyafterthecommand. Thenumberoftimesthecommandmustberepeated.Mustcomeafter,tonotbe interpretedasanaddress. Fileaffectedbythecommand.%standsforcurrentfileand#isthepreviousfile.

Meaning

[address]codestination Copythelinesspecifiedintheaddresstodestination. Examples: :1,10co50(copythefirst10linestojustafterline50) [address]d[register] Deletethelinesspecifiedintheaddess. Examples: :/PartI/,/PartII/1d(deletetolineabovePartII) :/main/+d(deletelinebelowmain) :.,$dx(deletefromtheactuallinetolastline,andstoreinregiterx) [address]mdestination Movethelinesspecifiedintheaddresstodestination. Examples: :1,10m50(movethefirst10linestojustafterline50) [address]pu[char] Putthepreviousdeletedfromnamedregisterchartothelinespecifiedby address.

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

Command

Meaning

[address]s Substitutethefirstinstanceofpatternoneachspecifiedlines(address) [/pattern/replacement/] withthereplacement.Countspecifiesthenumberoflinetoexecutestarting [options][count] tocountfromaddress. Options: cPromptforconfirmationbeforeeachsubstitution. gSubstituteallinstancesofpatternoneachline(global) Examples: :1,10s/yes/no/g(Substituteinfirst10lines) :%s/[Hh]ello/Hi/gc(confirmglobalsubstitutionstobeexecutedinalllines) [address]w[!][[>>]file] Writelinesspecifiedbyaddresstofile.If>>isused,thenappendtofile. Theoprtion!meanstoforcethewritingprocess. :1,10wfilename(copyfirst10linestofinename) :50w>>filename(appendline50tofilename) sedEDITOR Thesed(streameditor)isanoninteractiveeditor.Itinterpretsascriptandperformstheactions.Itisa usefuleditorforeditingmanyfilesautomatically. CommandLineSyntax: sed'command'file(s) sedfscriptfilefile(s) SyntaxofsedCommands: [address[,address]][!]command[arguments] Address /pattern/ N $ noaddress Meaning Linesthatmatchpattern. /BSD/d(deletelinesconatiningBSD) LinenumberN. Lastline. Eachinputline. s/xx/yy/g(substituteonalllines)

CompiledbyAluiziousingthebookUNIXINANUTSHELL,ArnoldRobbins,O'ReillyEd.,4thedition,2005,ISBN0596100299.

Address Oneaddress

Meaning Anylinematchingtheaddress

Firstmatchinglineandallsucceedinglinesuptoandincludinga Twocommaseparetedaddresses linematchingthesecondaddress. /^begin/,/^end/p(printbetweenbeginandend,inclusive) Anaddressfollowedby! Commands: Command [address]a\text Appendtextfollowingeachlinethatmatchtheaddress. Iftextextendsmorethanoneline,useabackslash(\)attheendofthe linetobeginthenewline.LastlinedoesNOThavethe\(changeline). $a\ Thisisthefirstlineoftext\ secondline\ lastline. Changethelinesselectedbytheaddresseswithtext.Textfollowthe samerulesasusedforappend(a\). 1,100c\ firstline\ secondline. Deletethelinesspecifiedbytheaddress. Substitutepatterntoreplacementoneachlineaddressed.Theflagsare: nreplacethenthinstanceofpatternineachlineinsteadofthe1st (default) greplaceallinstanceofpatternoneachlineaddressed(global). Translatecharacters.Changeeveryinstanceofatox,btoy,ctoz,etc. AlllinesthatdoNOTmatchtheaddress.

[address[,address]]c\text

[address[,address]]d [address[,address]]s/ pattern/replacement/[flags]

[address[,address]]y/ abc/xyz/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy