关闭

关闭

封号提示

内容

首页 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 评分 5 0 333 45 1513 暂无简介 简介 举报

简介:本文档为《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

类似资料

编辑推荐

Pro.PHP.and.jQuery.pdf

销售就是要搞定人.pdf

晶体管电路设计上.pdf

第1讲_推土机概论.ppt

云南省 洱源县志.pdf

职业精品

精彩专题

上传我的资料

精选资料

热门资料排行换一换

  • Convergence_of_F…

  • 梁红玉故事01慧眼识英雄-潘伟 …

  • 梁红玉故事02金兀术入寇-潘伟 …

  • 梁红玉故事03夫妻守大江-潘伟 …

  • 梁红玉故事04抗命斥钦差-潘伟 …

  • 梁红玉故事05拦江擒顽敌-潘伟 …

  • 梁红玉故事08金山擂战鼓-潘伟 …

  • [甘肃杨家将]1.杨业归宋.pdf

  • 梁红玉故事07黄天荡大战+潘伟 …

  • 资料评价:

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

    意见
    反馈

    返回
    顶部