首页 vi.and.Vim.Editors.Pocket.Reference.2nd.Edition…

vi.and.Vim.Editors.Pocket.Reference.2nd.Edition.pdf

vi.and.Vim.Editors.Pocket.Refer…

上传者: yjice 2011-06-07 评分1 评论0 下载639 收藏0 阅读量1512 暂无简介 简介 举报

简介:本文档为《vi.and.Vim.Editors.Pocket.Reference.2nd.Editionpdf》,可适用于IT书籍领域,主题内容包含viandVimEditorsPocketReferenceSECONDEDITIONviandVimEditorsPocketReferenceA符等。

viandVimEditorsPocketReferenceSECONDEDITIONviandVimEditorsPocketReferenceArnoldRobbinsBeijing•Cambridge•Farnham•Köln•Sebastopol•TokyoviandVimEditorsPocketReference,SecondEditionbyArnoldRobbinsCopyrightArnoldRobbinsAllrightsreservedPrintedinCanadaPublishedbyO’ReillyMedia,Inc,GravensteinHighwayNorth,Sebastopol,CAO’Reillybooksmaybepurchasedforeducational,business,orsalespromotionaluseOnlineeditionsarealsoavailableformosttitles(http:mysafaribooksonlinecom)Formoreinformation,contactourcorporateinstitutionalsalesdepartment:()orcorporateoreillycomEditor:AndyOramCopyeditor:AmyThomsonProductionEditor:AdamZarembaProofreader:SadaPreischIndexer:JohnBickelhauptCoverDesigner:KarenMontgomeryInteriorDesigner:DavidFutatoIllustrator:RobertRomanoPrintingHistory:January:FirstEditionJanuary:SecondEditionNutshellHandbook,theNutshellHandbooklogo,andtheO’ReillylogoareregisteredtrademarksofO’ReillyMedia,IncviandVimEditorsPocketReference,theimageofatarsier,andrelatedtradedressaretrademarksofO’ReillyMedia,IncManyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedastrademarksWherethosedesignationsappearinthisbook,andO’ReillyMedia,Inc,wasawareofatrademarkclaim,thedesignationshavebeenprintedincapsorinitialcapsWhileeveryprecautionhasbeentakeninthepreparationofthisbook,thepublisherandauthorassumenoresponsibilityforerrorsoromissions,orfordamagesresultingfromtheuseoftheinformationcontainedhereinISBN:TMContentsviandVimEditorsPocketReferenceIntroductionConventionsAcknowledgmentsCommandLineOptionsviCommandsInputModeShortcutsSubstitutionandRegularExpressionsexCommandsInitializationRecoveryvisetOptionsNothingliketheOriginalEnhancedTagsandTagStacksVimviImprovednviNewvielvisvilevilikeEmacsInternetResourcesforviProgramSourceandContactInformationIndexvviandVimEditorsPocketReferenceIntroductionThispocketreferenceisacompaniontoLearningtheviandVimEditors,byArnoldRobbinsetalItdescribesthevicommandlineoptions,commandmodecommands,excommandsandoptions,regularexpressionsandtheuseofthesubstitute(s)command,andotherpertinentinformationforusingviWhileretainingcoverageoftheviclones,nvi,elvis,andvile,thiseditionoffersexpandedcoverageoftheVimeditor,whichhasbecomethedefactostandardversionofviintheGNULinuxworldTheSolarisversionofviservedasthe“reference”versionoftheoriginalviforthispocketreferenceConventionsThefollowingfontconventionsareusedinthisbook:CourierUsedforfilenames,commandnames,options,andeverythingtobetypedliterallyCourierItalicUsedforreplaceabletextwithincommandsItalicUsedforreplaceabletextwithinregulartext,InternetURLs,foremphasis,andfornewtermswhenfirstdefinedIdentifiesoptionaltextthebracketsarenottypedCTRLGIndicatesakeystrokeAcknowledgmentsThankstoRobertPJDayandElbertHannah,whoreviewedthiseditionTheproductionteamatO’ReillyMediadidagreatjobhelpingmemakethebooklookthewayIwantedAspecialthankstomyeditor,AndyOram,forkeepingtheprojectmovingwithcontinualgentleencouragementCommandLineOptionsCommandActionvifileInvokevionfilevifilefileInvokevionfilessequentiallyviewfileInvokevionfileinreadonlymodeviRfileInvokevionfileinreadonlymodevirfileRecoverfileandrecenteditsafteracrashvittagLookuptagandstarteditingatitsdefinitionviwnSetthewindowsizetonusefuloveraslowconnectionvifileOpenfileatlastlinevinfileOpenfiledirectlyatlinenumbern|viandVimEditorsPocketReferenceCommandActionviccommandfileOpenfile,executecommand,whichisusuallyasearchcommandorlinenumber(POSIX)vipatternfileOpenfiledirectlyatpatternexfileInvokeexonfileexfile<scriptInvokeexonfile,takingcommandsfromscriptsuppressinformativemessagesandpromptsexsfile<scriptInvokeexonfile,takingcommandsfromscriptsuppressinformativemessagesandprompts(POSIX)viCommandsvicommandsareusedin“screen”mode(thedefault),whereyouusethecommandstomovearoundthescreenandtoperformoperationsonthetextMostvicommandsfollowageneralpattern:commandnumbertextobjectortheequivalentform:numbercommandtextobjectMovementCommandsvimovementcommandsdistinguishbetweentwokindsof“words”Thelowercasecommandsdefineawordasacontiguoussequenceofunderscores,letters,anddigitsTheuppercasecommandsdefineawordasacontiguoussequenceofnonwhitespacecharactersviCommands|CommandMeaningCharacterh,j,k,lLeft,down,up,right(,,,)Textw,W,b,BForward,backwardbyworde,EEndofword),(Beginningofnext,previoussentence},{Beginningofnext,previousparagraph,Beginningofnext,previoussectionLinesENTERFirstnonblankcharacterofnextline,$First,lastpositionofcurrentline^Firstnonblankcharacterofcurrentline,Firstnonblankcharacterofnext,previouslinen|ColumnnofcurrentlineH,M,LTop,middle,lastlineofscreennHn(number)oflinesaftertoplinenLn(number)oflinesbeforelastlineScrollingCTRLF,CTRLBScrollforward,backwardonescreenCTRLDCTRLUScrolldown,uponehalfscreenCTRLECTRLYShowonemorelineatbottom,topofwindowzENTERRepositionlinewithcursor:totopofscreenzRepositionlinewithcursor:tomiddleofscreenz–Repositionlinewithcursor:tobottomofscreenCTRLLRedrawscreen(withoutscrolling)|viandVimEditorsPocketReferenceCommandMeaningSearchespatternSearchforwardforpatternpatternSearchbackwardforpatternn,NRepeatlastsearchinsame,oppositedirection,Repeatprevioussearchforward,backwardfxSearchforwardforcharacterxincurrentlineFxSearchbackwardforcharacterxincurrentlinetxSearchforwardtocharacterbeforexincurrentlineTxSearchbackwardtocharacterafterxincurrentlineRepeatpreviouscurrentlinesearch,RepeatpreviouscurrentlinesearchinoppositedirectionLinenumberCTRLGDisplaycurrentlinenumbernGMovetolinenumbernGMovetolastlineinfile:nMovetolineninfileMarkingpositionmxMarkcurrentpositionasx‘xMovecursortomarkx(graveaccent)‘‘Returntopreviousmarkorcontext(twograveaccents)’xMovetobeginningoflinecontainingmarkx(singlequote)’’Returntobeginningoflinecontainingpreviousmark(twosinglequotes)viCommands|EditingCommandsCommandActionInserti,aInserttextbefore,aftercursorI,AInserttextbeforebeginning,afterendoflineo,OOpennewlinefortextbelow,abovecursorChangecwChangewordccChangecurrentlinecmotionChangetextbetweenthecursorandthetargetofmotionCChangetoendoflinerReplacesinglecharacterRTypeover(overwrite)characterssSubstitute:deletecharacterandinsertnewtextSSubstitute:deletecurrentlineandinsertnewtextDelete,movexDeletecharacterundercursorXDeletecharacterbeforecursordwDeletewordddDeletecurrentlinedmotionDeletetextbetweenthecursorandthetargetofmotionDDeletetoendoflinep,PPutdeletedtextafter,beforecursor"npPuttextfromdeletebuffernumbernaftercursor(forlastninedeletions)YankywYank(copy)word|viandVimEditorsPocketReferenceCommandActionyyYankcurrentline"ayyYankcurrentlineintonamedbuffera(a–z)uppercasenamesappendtextymotionYanktextbetweenthecursorandthetargetofmotionp,PPutyankedtextafter,beforecursor"aPPuttextfrombufferabeforecursor(a–z)OthercommandsRepeatlasteditcommandu,UUndolasteditrestorecurrentlineJJointwolinesexeditcommands:dDeletelines:mMovelines:coor:tCopylines:,$dDeletefromcurrentlinetoendoffile:,mMovelinesthroughtotopoffile:,patternco$CopyfromcurrentlinethroughlinecontainingpatterntoendoffileExitCommandsCommandMeaning:wWrite(save)file:w!Write(save)file,overridingprotection:wqWrite(save)andquitfile:xWrite(save)andquitfileZZWrite(save)andquitfile:,wnewfileWritefromlinethroughlineasnewfile:,w>>fileWritefromlinethroughlineandappendtofileviCommands|CommandMeaning:wnewWritecurrentbuffernamedfileasfilenew:qQuitfile:q!Quitfile,overridingprotectionQQuitviandinvokeex:efileEditfilewithoutleavingvi:nEditnextfile:e!Returntoversionofcurrentfileasoftimeoflastwrite(save):e#Editalternatefile:viInvokevieditorfromex:InvokeoneexcommandfromvieditorCurrentfilename(substitutesintoexcommandline)#Alternatefilename(substitutesintoexcommandline)SolarisviCommandModeTagCommandsCommandAction^Lookupthelocationoftheidentifierunderthecursorinthetagsfileandmovetothatlocationiftagstackingisenabled,thecurrentlocationisautomaticallypushedontothetagstack^TReturntothepreviouslocationinthetagstack,ie,popoffoneelementBufferNamesBuffernamesBufferuse–Thelastninedeletions,frommosttoleastrecenta–zNamedbufferstouseasneededuppercaselettersappendtotherespectivebuffers|viandVimEditorsPocketReferenceBufferandMarkingCommandsCommandMeaning"bcommandDocommandwithbufferbmxMarkcurrentpositionwithx‘xMovecursortocharactermarkedbyx(graveaccent)‘‘Returntoexactpositionofpreviousmarkorcontext(twograveaccents)’xMovecursortofirstcharacteroflinemarkedbyx(singlequote)’’Returntobeginningofthelineofpreviousmarkorcontext(twosinglequotes)InputModeShortcutsviprovidestwowaystodecreasetheamountoftypingyouhavetodo:abbreviationsandmapsWordAbbreviation:ababbrphraseDefineabbrasanabbreviationforphrase:abListalldefinedabbreviations:unababbrRemovedefinitionofabbrCommandandInputModeMaps:mapxsequenceDefinecharacter(s)xasasequenceofeditingcommands:unmapxDisablethesequencedefinedforx:mapListthecharactersthatarecurrentlymappedInputModeShortcuts|:map!xsequenceDefinecharacter(s)xasasequenceofeditingcommandsortextthatwillberecognizedininsertmode:unmap!xDisablethesequencedefinedfortheinsertmodemapx:map!ListthecharactersthatarecurrentlymappedforinterpretationininsertmodeForbothcommandandinsertmodemaps,themapnamexcantakeseveralforms:OnecharacterWhenyoutypethecharacter,viexecutestheassociatedsequenceofcommandsMultiplecharactersAllthecharactersmustbetypedwithinonesecondThevalueofnotimeoutchangesthebehavior#nFunctionkeynotation:a#followedbyadigitnrepresentsthesequenceofcharacterssentbythekeyboard’sfunctionkeynumbernToentercharacterssuchasEscape(^)orcarriagereturn(^M),firsttypeCTRLV(^V)ExecutableBuffersNamedbuffersprovideyetanotherwaytocreate“macros”complexcommandsequencesyoucanrepeatwithafewkeystrokesHere’showit’sdone:TypeavicommandsequenceoranexcommandprecededbyacolonreturntocommandmodeDeletethetextintoanamedbufferExecutethebufferwiththecommandfollowedbythebufferletterTheexcommand:bufnameworkssimilarly|viandVimEditorsPocketReferenceSomeversionsofvitreat*identicallytowhenusedfromtheexcommandlineInaddition,ifthebuffercharactersuppliedaftertheor*commandsis*,thecommandistakenfromthedefault(unnamed)bufferAutomaticIndentationEnableautomaticindentationwiththefollowingcommand::setautoindentFourspecialinputsequencesaffectautomaticindentation:^TAddonelevelofindentationtypedininsertmode^DRemoveonelevelofindentationtypedininsertmode^^DShiftthecursorbacktothebeginningoftheline,butonlyforthecurrentline*^DShiftthecursorbacktothebeginningofthelineandresetthecurrentautoindentleveltozero†Twocommandscanbeusedforshiftingsourcecode:<<Shiftalinelefteightspaces>>ShiftalinerighteightspacesThedefaultshiftisthevalueofshiftwidth,usuallyeightspacesSubstitutionandRegularExpressionsRegularexpressions,andtheirusewiththesubstitutecommand,arewhatgivevimostofitssignificanteditingpower*^^Dand^Darenotinelvis†Thenvidocumentationhasthesetwocommandsswitched,buttheprogramactuallybehavesasdescribedhereSubstitutionandRegularExpressions|TheSubstituteCommandThegeneralformofthesubstitutecommandis::addr,addrsoldnewflagsOmittingthesearchpattern(:sreplacement)usesthelastsearchorsubstitutionregularexpressionAnemptyreplacementpart(:spattern)“replaces”thematchedtextwithnothing,effectivelydeletingitfromthelineSubstitutionflagsFlagMeaningcConfirmeachsubstitutiongChangealloccurrencesofoldtonewoneachline(globally)pPrintthelineafterthechangeismadeIt’softenusefultocombinethesubstitutecommandwiththeexglobalcommand,:g::gObjectOrientedsBuzzwordcompliantgviRegularExpressions(period)MatchesanysinglecharacterexceptanewlineRememberthatspacesaretreatedascharacters*Matcheszeroormore(asmanyasthereare)ofthesinglecharacterthatimmediatelyprecedesitThe*canfollowametacharacter,suchas,orarangeinbrackets^Whenusedatthestartofaregularexpression,^requiresthatthefollowingregularexpressionbefoundatthebeginningofthelineWhennotatthebeginningofaregularexpression,^standsforitself$Whenusedattheendofaregularexpression,$requiresthattheprecedingregularexpressionbefoundattheend|viandVimEditorsPocketReferenceofthelineWhennotattheendofaregularexpression,$standsforitselfTreatsthefollowingspecialcharacterasanordinarycharacterUsetogetaliteralbackslash~MatcheswhateverregularexpressionwasusedinthelastsearchMatchesanyoneofthecharactersenclosedbetweenthebracketsArangeofconsecutivecharacterscanbespecifiedbyseparatingthefirstandlastcharactersintherangewithahyphenYoucanincludemorethanonerangeinsidebracketsandspecifyamixofrangesandseparatecharactersMostmetacharacterslosetheirspecialmeaninginsidebrackets,soyoudon’tneedtoescapethemifyouwanttousethemasordinarycharactersWithinbrackets,thethreemetacharactersyoustillneedtoescapeareThehyphen()acquiresmeaningasarangespecifiertouseanactualhyphen,youcanalsoplaceitasthefirstcharacterinsidethebracketsAcaret(^)hasspecialmeaningonlywhenit’sthefirstcharacterinsidethebrackets,butinthiscase,themeaningdiffersfromthatofthenormal^metacharacterAsthefirstcharacterwithinbrackets,a^reversestheirsense:thebracketsmatchanyonecharacternotinthelistForexample,^azmatchesanycharacterthat’snotalowercaseletterCAUTIONOnmodernsystems,thelocalecanaffecttheinterpretationofrangeswithinbrackets,causingvitomatchlettersinasurprisingfashionItisbettertousePOSIXbracketexpressions(see“POSIXBracketExpressions”onpage)tomatchspecifickindsofcharacters,suchasalllowercaseoralluppercasecharactersSubstitutionandRegularExpressions|()Savesthepatternenclosedbetween(and)intoaspecialholdingspaceor“holdbuffer”YoucansaveuptoninepatternsinthiswayonasinglelineYoucanalsousethennotationwithinasearchorsubstitutestring::s(abcd)alphabetsoupchangesabcdabcdintoalphabetsoup‡<>Matchescharactersatthebeginning(<)orend(>)ofawordTheendorbeginningofawordisdeterminedeitherbyapunctuationmarkorbyaspaceUnlike(),thesedon’thavetobeusedinmatchedpairsPOSIXBracketExpressionsPOSIXbracketexpressionsmaycontainthefollowing:CharacterclassesAPOSIXcharacterclassconsistsofkeywordsbracketedby:and:Thekeywordsdescribedifferentclassesofcharacters,suchasalphabeticcharacters,controlcharacters,andsoon(seethefollowingtable)CollatingsymbolsAcollatingsymbolisamulticharactersequencethatshouldbetreatedasaunitItconsistsofthecharactersbracketedbyandEquivalenceclassesAnequivalenceclasslistsasetofcharactersthatshouldbeconsideredequivalent,suchaseandèItconsistsofanamedelementfromthelocale,bracketedby=and=Allthreeconstructsmustappearinsidethesquarebracketsofabracketexpression‡Thisworkswithvi,nvi,andVim,butnotwithelvisorvile|viandVimEditorsPocketReferencePOSIXcharacterclassesClassMatchingcharacters:alnum:Alphanumericcharacters:alpha:Alphabeticcharacters:blank:Spaceandtabcharacters:cntrl:Controlcharacters:digit:Numericcharacters:graph:Printableandvisible(nonspace)characters:lower:Lowercasecharacters:print:Printablecharacters(includeswhitespace):punct:Punctuationcharacters:space:Whitespacecharacters:upper:Uppercasecharacters:xdigit:HexadecimaldigitsMetacharactersUsedinReplacementStringsnIsreplacedwiththetextmatchedbythenthpatternpreviouslysavedby(and),wherenisanumberfromonetonine,andpreviouslysavedpatterns(keptinholdbuffers)arecountedfromtheleftonthelineTreatsthefollowingspecialcharacterasanordinarycharacterTospecifyarealbackslash,typetwoinarow()IsreplacedwiththeentiretextmatchedbythesearchpatternwhenusedinareplacementstringThisisusefulwhenyouwanttoavoidretypingtext~ThestringfoundisreplacedwiththereplacementtextspecifiedinthelastsubstitutecommandThisisusefulforrepeatinganedituorlChangesthenextcharacterinthereplacementstringtouppercaseorlowercase,respectivelySubstitutionandRegularExpressions|UorLandeorEUandLaresimilartouorl,butallfollowingcharactersareconvertedtouppercaseorlowercaseuntiltheendofthereplacementstringoruntileorEisreachedIfthereisnoeorE,allcharactersofthereplacementtextareaffectedbytheUorLMoreSubstitutionTricks•Youcaninstructvitoignorecasebytyping:setic•Asimple:sisthesameas:s~•:isthesameas:sYoucanfollowthewithgtomakethesubstitutiongloballyontheline,andevenuseitwithalinerange•Youcanusethekeyasavicommandtoperformthe:command,ie,torepeatthelastsubstitution•The:~commandissimilartothe:command,butwithasubtledifferenceThesearchpatternusedisthelastre

职业精品

酒店承包合同范本.doc

某企业人力资源制度.doc

员工离职处理原则.docx

PDF转word方法全面盘点1.doc

用户评论

0/200
    暂无评论
上传我的资料

精彩专题

相关资料换一换

资料评价:

/ 94
所需积分:0 立即下载

意见
反馈

返回
顶部