加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 vi和Vim编辑器袖珍参考手册(第2版) 文字版

vi和Vim编辑器袖珍参考手册(第2版) 文字版.pdf

vi和Vim编辑器袖珍参考手册(第2版) 文字版

方砖
2011-09-21 0人阅读 举报 0 0 暂无简介

简介:本文档为《vi和Vim编辑器袖珍参考手册(第2版) 文字版pdf》,可适用于IT/计算机领域

viandVimEditorsPocketReferenceSECONDEDITIONviandVimEditorsPocketReferenceArnoldRobbinsBeijing•Cambridge•Farnham•Köln•Sebastopol•TokyoDownloadfromWow!eBook<wwwwowebookcom>viandVimEditorsPocketReference,SecondEditionbyArnoldRobbinsCopyright©ArnoldRobbinsAllrightsreservedPrintedinCanadaPublishedbyO’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:TMContentsviandVimEditorsPocketReferenceIntroductionConventionsAcknowledgmentsCommandLineOptionsviCommandsInputModeShortcutsSubstitutionandRegularExpressionsexCommandsInitializationRecoveryvisetOptionsNothingliketheOriginalEnhancedTagsandTagStacksVimviImprovednviNewvielvisvilevilikeEmacsInternetResourcesforviProgramSourceandContactInformationIndexvDownloadfromWow!eBook<wwwwowebookcom>viandVimEditorsPocketReferenceIntroductionThispocketreferenceisacompaniontoLearningtheviandVimEditors,byArnoldRobbinsetalItdescribesthevicommandlineoptions,commandmodecommands,excommandsandoptions,regularexpressionsandtheuseofthesubstitute(s)command,andotherpertinentinformationforusingviWhileretainingcoverageoftheviclones,nvi,elvis,andvile,thiseditionoffersexpandedcoverageoftheVimeditor,whichhasbecomethedefactostandardversionofviintheGNULinuxworldTheSolarisversionofviservedasthe“reference”versionoftheoriginalviforthispocketreferenceConventionsThefollowingfontconventionsareusedinthisbook:CourierUsedforfilenames,commandnames,options,andeverythingtobetypedliterallyDownloadfromWow!eBook<wwwwowebookcom>CourierItalicUsedforreplaceabletextwithincommandsItalicUsedforreplaceabletextwithinregulartext,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|DownloadfromWow!eBook<wwwwowebookcom>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,backwardonescreenCTRLD,CTRLUScrolldown,uponehalfscreenCTRLE,CTRLYShowonemorelineatbottom,topofwindowzENTERRepositionlinewithcursor:totopofscreenzRepositionlinewithcursor:tomiddleofscreenz–Repositionlinewithcursor:tobottomofscreenCTRLLRedrawscreen(withoutscrolling)|viandVimEditorsPocketReferenceDownloadfromWow!eBook<wwwwowebookcom>CommandMeaningSearchespatternSearchforwardforpatternpatternSearchbackwardforpatternn,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|DownloadfromWow!eBook<wwwwowebookcom>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|DownloadfromWow!eBook<wwwwowebookcom>: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|DownloadfromWow!eBook<wwwwowebookcom>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|viandVimEditorsPocketReferenceDownloadfromWow!eBook<wwwwowebookcom>POSIXcharacterclassesClassMatchingcharacters: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,butallf

用户评价(1)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/18

vi和Vim编辑器袖珍参考手册(第2版) 文字版

仅供在线阅读

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利