viper.texi 176 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557
  1. % -*-texinfo-*-
  2. \input texinfo
  3. @comment Using viper.info instead of viper in setfilename breaks DOS.
  4. @comment @setfilename viper
  5. @comment @setfilename viper.info
  6. @setfilename ../../info/viper.info
  7. @include docstyle.texi
  8. @copying
  9. Copyright @copyright{} 1995--1997, 2001--2015 Free Software Foundation, Inc.
  10. @quotation
  11. Permission is granted to copy, distribute and/or modify this document
  12. under the terms of the GNU Free Documentation License, Version 1.3 or
  13. any later version published by the Free Software Foundation; with no
  14. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
  15. and with the Back-Cover Texts as in (a) below. A copy of the license
  16. is included in the section entitled ``GNU Free Documentation License''.
  17. (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
  18. modify this GNU manual.''
  19. @end quotation
  20. @end copying
  21. @dircategory Emacs misc features
  22. @direntry
  23. * VIPER: (viper). A VI-emulation mode for Emacs.
  24. @end direntry
  25. @finalout
  26. @titlepage
  27. @title Viper Is a Package for Emacs Rebels
  28. @subtitle a Vi emulator for Emacs
  29. @subtitle November 2008, Viper Version 3.11.2
  30. @author Michael Kifer (Viper)
  31. @author Aamod Sane (VIP 4.4)
  32. @author Masahiko Sato (VIP 3.5)
  33. @page
  34. @vskip 0pt plus 1filll
  35. @insertcopying
  36. @end titlepage
  37. @contents
  38. @ifnottex
  39. @node Top
  40. @top Viper
  41. We believe that one or more of the following statements are adequate
  42. descriptions of Viper:
  43. @example
  44. Viper Is a Package for Emacs Rebels;
  45. it is a VI Plan for Emacs Rescue
  46. and/or a venomous VI PERil.
  47. @end example
  48. Technically speaking, Viper is a Vi emulation package for Emacs. It
  49. implements all Vi and Ex commands, occasionally improving on them and
  50. adding many new features. It gives the user the best of both worlds: Vi
  51. keystrokes for editing combined with the power of the Emacs environment.
  52. Viper emulates Vi at several levels, from the one that closely follows Vi
  53. conventions to the one that departs from many of them. It has many
  54. customizable options, which can be used to tailor Viper to the work habits
  55. of various users.
  56. This manual describes Viper, concentrating on the differences from Vi and
  57. new features of Viper.
  58. Viper, formerly known as VIP-19, was written by Michael Kifer. It is based
  59. on VIP version 3.5 by Masahiko Sato and VIP version 4.4 by Aamod Sane.
  60. About 15% of the code still comes from those older packages.
  61. Viper is intended to be usable without reading this manual; the defaults
  62. are set to make Viper as close to Vi as possible. At startup, Viper will
  63. try to set the most appropriate default environment for you, based on
  64. your familiarity with Emacs. It will also tell you the basic GNU Emacs window
  65. management commands to help you start immediately.
  66. Although this manual explains how to customize Viper, some basic
  67. familiarity with Emacs Lisp is a plus.
  68. It is recommended that you read the Overview node. The other nodes may
  69. be visited as needed.
  70. Comments and bug reports are welcome.
  71. @code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
  72. Please use the Ex command @kbd{:submitReport} for this purpose.
  73. @insertcopying
  74. @end ifnottex
  75. @menu
  76. * Overview:: Read for a smoother start
  77. * Improvements over Vi:: New features, Improvements
  78. * Customization:: How to customize Viper
  79. * Commands:: Vi and Ex Commands
  80. * GNU Free Documentation License:: The license for this documentation.
  81. * Acknowledgments::
  82. * Key Index:: Index of Vi and Ex Commands
  83. * Function Index:: Index of Viper Functions
  84. * Variable Index:: Index of Viper Variables
  85. * Package Index:: Index of Packages Mentioned in this Document
  86. * Concept Index:: Vi, Ex and Emacs concepts
  87. @end menu
  88. @iftex
  89. @unnumbered Introduction
  90. We believe that one or more of the following statements are adequate
  91. descriptions of Viper:
  92. @example
  93. Viper Is a Package for Emacs Rebels;
  94. it is a VI Plan for Emacs Rescue
  95. and/or a venomous VI PERil.
  96. @end example
  97. Viper is a Vi emulation package for Emacs. Viper contains virtually all
  98. of Vi and Ex functionality and much more. It gives you the best of both
  99. worlds: Vi keystrokes for editing combined with the GNU Emacs
  100. environment. Viper also fixes some common complaints with Vi commands.
  101. This manual describes Viper, concentrating on the differences from Vi
  102. and on the new features of Viper.
  103. Viper was written by Michael Kifer. It is based on VIP version 3.5 by
  104. Masahiko Sato and VIP version 4.4 by Aamod Sane. About 15% of the code
  105. still comes from those older packages.
  106. Viper is intended to be usable out of the box, without reading this manual;
  107. the defaults are set to make Viper as close to Vi as possible. At
  108. startup, Viper will attempt to set the most appropriate default environment
  109. for you, based on your familiarity with Emacs. It will also tell you the
  110. basic GNU Emacs window management commands to help you start immediately.
  111. Although this manual explains how to customize Viper, some basic
  112. familiarity with Emacs Lisp is a plus.
  113. It is recommended that you read the chapter Overview. The other chapters
  114. will be useful for customization and advanced usage.
  115. You should also learn to use the Info on-line hypertext manual system that
  116. comes with Emacs. This manual can be read as an Info file. Try the command
  117. @kbd{@key{ESC} x info} with vanilla Emacs sometime.
  118. Comments and bug reports are welcome.
  119. @code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
  120. Please use the Ex command @kbd{:submitReport} for this purpose.
  121. @end iftex
  122. @node Overview
  123. @chapter Overview of Viper
  124. Viper is a Vi emulation on top of Emacs. At the same time, Viper provides a
  125. virtually unrestricted access to Emacs facilities. Perfect compatibility
  126. with Vi is possible but not desirable. This chapter tells you about the
  127. Emacs ideas that you should know about, how to use Viper within Emacs and
  128. some incompatibilities.
  129. This manual is written with the assumption that you are an experienced Vi
  130. user who wants to switch to Emacs while retaining the ability to edit files
  131. Vi style. Incredible as it might seem, there are experienced Emacs users
  132. who use Viper as a backdoor into the superior (as every Vi user already knows)
  133. world of Vi! These users are well familiar with Emacs bindings and prefer them
  134. in some cases, especially in the Vi Insert state. John Hawkins
  135. <jshawkin@@eecs.umich.edu> has provided a set of customizations, which
  136. enables additional Emacs bindings under Viper. These customizations can be
  137. included in your @file{~/.emacs.d/viper} file and are found at the
  138. following URL: @file{http://traeki.freeshell.org/files/viper-sample}.
  139. @menu
  140. * Emacs Preliminaries:: Basic concepts in Emacs.
  141. * Loading Viper:: Loading and Preliminary Configuration.
  142. * States in Viper:: Viper has four states orthogonal to Emacs
  143. modes.
  144. * The Minibuffer:: Command line in Emacs.
  145. * Multiple Files in Viper:: True multiple file handling.
  146. * Unimplemented Features:: That are unlikely to be implemented.
  147. @end menu
  148. @node Emacs Preliminaries
  149. @section Emacs Preliminaries
  150. @cindex buffer
  151. @cindex point
  152. @cindex mark
  153. @cindex text
  154. @cindex looking at
  155. @cindex end (of buffer)
  156. @cindex end (of line)
  157. @cindex region
  158. Emacs can edit several files at once. A file in Emacs is placed in a
  159. @dfn{buffer} that usually has the same name as the file. Buffers are also used
  160. for other purposes, such as shell interfaces, directory editing, etc.
  161. @xref{Dired,,Directory Editor,emacs,The
  162. GNU Emacs Manual}, for an example.
  163. A buffer has a distinguished position called the @dfn{point}.
  164. A @dfn{point} is always between 2 characters, and is @dfn{looking at}
  165. the right hand character. The cursor is positioned on the right hand
  166. character. Thus, when the @dfn{point} is looking at the end-of-line,
  167. the cursor is on the end-of-line character, i.e., beyond the last
  168. character on the line. This is the default Emacs behavior.
  169. The default settings of Viper try to mimic the behavior of Vi, preventing
  170. the cursor from going beyond the last character on the line. By using
  171. Emacs commands directly (such as those bound to arrow keys), it is possible
  172. to get the cursor beyond the end-of-line. However, this won't (or
  173. shouldn't) happen if you restrict yourself to standard Vi keys, unless you
  174. modify the default editing style. @xref{Customization}.
  175. In addition to the @dfn{point}, there is another distinguished buffer
  176. position called the @dfn{mark}. @xref{Mark,,Mark,emacs,The GNU Emacs
  177. manual}, for more info on the mark. The text between the @dfn{point} and
  178. the @dfn{mark} is called the @dfn{region} of the buffer. For the Viper
  179. user, this simply means that in addition to the Vi textmarkers a--z, there
  180. is another marker called @dfn{mark}. This is similar to the unnamed Vi
  181. marker used by the jump commands @kbd{``} and @kbd{''}, which move the
  182. cursor to the position of the last absolute jump. Viper provides access to
  183. the region in most text manipulation commands as @kbd{r} and @kbd{R} suffix
  184. to commands that operate on text regions, e.g., @kbd{dr} to delete region,
  185. etc.
  186. Furthermore, Viper lets Ex-style commands to work on the current region.
  187. This is done by typing a digit argument before @kbd{:}. For instance,
  188. typing @kbd{1:} will prompt you with something like @emph{:123,135},
  189. assuming that the current region starts at line 123 and ends at line
  190. 135. There is no need to type the line numbers, since Viper inserts them
  191. automatically in front of the Ex command.
  192. @xref{Basics}, for more info.
  193. @cindex window
  194. @cindex mode line
  195. @cindex buffer information
  196. @cindex Minibuffer
  197. @cindex command line
  198. @cindex buffer (modified)
  199. Emacs divides the screen into tiled @dfn{windows}. You can see the
  200. contents of a buffer through the window associated with the buffer. The
  201. cursor of the screen is positioned on the character after @dfn{point}.
  202. Every window has a @dfn{mode line} that displays information about the buffer.
  203. You can change the format of the mode
  204. line, but normally if you see @samp{**} at the beginning of a mode line it
  205. means that the buffer is @dfn{modified}. If you write out the contents of
  206. a buffer to a file, then the buffer will become not modified. Also if
  207. you see @samp{%%} at the beginning of the mode line, it means that the file
  208. associated with the buffer is write protected. The mode line will also
  209. show the buffer name and current major and minor modes (see below).
  210. A special buffer called @dfn{Minibuffer} is displayed as the last line
  211. in a minibuffer window. The minibuffer window is used for command input
  212. output. Viper uses minibuffer window for @kbd{/} and @kbd{:}
  213. commands.
  214. @cindex mode
  215. @cindex keymap
  216. @cindex local keymap
  217. @cindex global keymap
  218. @cindex major mode
  219. @cindex minor mode
  220. An Emacs buffer can have a @dfn{major mode} that customizes Emacs for
  221. editing text of a particular sort by changing the functionality of the keys.
  222. Keys are defined using a @dfn{keymap} that records the bindings between
  223. keystrokes and
  224. functions. The @dfn{global keymap} is common to all the
  225. buffers. Additionally, each buffer has its @dfn{local keymap} that determines the
  226. @dfn{mode} of the buffer. If a function is bound to some key in the local
  227. keymap then that function will be executed when you type the key.
  228. If no function is bound to a key in the
  229. local map, however, the function bound to the key in the global map
  230. will be executed. @xref{Major Modes,Major Modes,Major Modes,emacs,The
  231. GNU Emacs Manual}, for more information.
  232. A buffer can also have a @dfn{minor mode}. Minor modes are options that
  233. you can use or not. A buffer in @code{text-mode} can have
  234. @code{auto-fill-mode} as minor mode, which can be turned off or on at
  235. any time. In Emacs, a minor mode may have it own keymap,
  236. which overrides the local keymap when the minor mode is turned on. For
  237. more information, @pxref{Minor Modes,Minor Modes,Minor Modes,emacs,The
  238. GNU Emacs Manual}.
  239. @cindex Viper as minor mode
  240. @cindex Control keys
  241. @cindex Meta key
  242. Viper is implemented as a collection of minor modes. Different minor modes
  243. are involved when Viper emulates Vi command mode, Vi insert mode, etc.
  244. You can also turn Viper on and off at any time while in Vi command mode.
  245. @xref{States in Viper}, for
  246. more information.
  247. Emacs uses Control and Meta modifiers. These are denoted as C and M,
  248. e.g., @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}. The Meta key is
  249. usually located on each side of the Space bar; it is used in a manner
  250. similar to the Control key, e.g., @kbd{M-x} means typing @kbd{x} while
  251. holding the Meta key down. For keyboards that do not have a Meta key,
  252. @key{ESC} is used as Meta. Thus @kbd{M-x} is typed as @kbd{@key{ESC}
  253. x}. Viper uses @key{ESC} to switch from Insert state to Vi state. Therefore
  254. Viper defines @kbd{C-\} as its Meta key in Vi state. @xref{Vi State}, for
  255. more info.
  256. Emacs is structured as a Lisp interpreter around a C core. Emacs keys
  257. cause Lisp functions to be called. It is possible to call these
  258. functions directly, by typing @kbd{M-x function-name}.
  259. @node Loading Viper
  260. @section Loading Viper
  261. The most common way to load it automatically is to include the following
  262. lines (in the given order!):
  263. @lisp
  264. (setq viper-mode t)
  265. (require 'viper)
  266. @end lisp
  267. @noindent
  268. in your @file{~/.emacs} file. The @file{.emacs} file is placed in your
  269. home directory and it is be executed every time you invoke Emacs. This is
  270. the place where all general Emacs customization takes place. Beginning with
  271. version 20.0, Emacsen have an interactive interface, which simplifies the
  272. job of customization significantly.
  273. Viper also uses the file @file{~/.emacs.d/viper} for Viper-specific customization.
  274. The location of Viper customization file can be changed by setting the
  275. variable @code{viper-custom-file-name} in @file{.emacs} @emph{prior} to loading
  276. Viper.
  277. The latest versions of Emacs have an interactive customization facility,
  278. which allows you to (mostly) bypass the use of the @file{.emacs} and
  279. @code{viper-custom-file-name} files. You can reach this customization
  280. facility from within Viper's VI state by executing the Ex command
  281. @kbd{:customize}.
  282. Once invoked, Viper will arrange to bring up Emacs buffers in Vi state
  283. whenever this makes sense.
  284. @xref{Packages that Change Keymaps}, to find out when forcing Vi command state
  285. on a buffer may be counter-productive.
  286. Even if your @file{.emacs} file does not invoke Viper automatically,
  287. you can still load Viper and enter the Vi command state by typing the
  288. following from within Emacs:
  289. @lisp
  290. M-x viper-mode
  291. @end lisp
  292. When Emacs first comes up, if you have not specified a file on the
  293. command line, it will show the @file{*scratch*} buffer, in the
  294. @samp{Lisp Interaction} mode. After you invoke Viper, you can start
  295. editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands.
  296. (@xref{File and Buffer Handling}, for more information on @kbd{v} and other
  297. new commands that, in many cases, are more convenient than @kbd{:e},
  298. @kbd{:vi}, and similar old-style Vi commands.)
  299. Finally, if at some point you would want to de-Viperize your running
  300. copy of Emacs after Viper has been loaded, the command @kbd{M-x
  301. viper-go-away} will do it for you. The function @code{toggle-viper-mode}
  302. toggles Viperization of Emacs on and off.
  303. @node States in Viper
  304. @section States in Viper
  305. @kindex @kbd{C-z}
  306. @kindex @key{ESC}
  307. @kindex @kbd{i}
  308. @cindex Emacs state
  309. @cindex Vi state
  310. @cindex Insert state
  311. @cindex Replace state
  312. @cindex Ex commands
  313. @findex @code{viper-go-away}
  314. @findex @code{toggle-viper-mode}
  315. Viper has four states, Emacs, Vi, Insert, and Replace.
  316. @table @samp
  317. @item Emacs state
  318. This is the state plain vanilla Emacs is normally in. After you have loaded
  319. Viper, @kbd{C-z} will normally take you to Vi command state. Another
  320. @kbd{C-z} will take you back to Emacs state. This toggle key can be
  321. changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to
  322. change to Vi state.
  323. For users who chose to set their user level to 1 at Viper setup time,
  324. switching to Emacs state is deliberately made harder in order to not
  325. confuse the novice user. In this case, @kbd{C-z} will either iconify Emacs
  326. (if Emacs runs as an application under X) or it will stop Emacs (if
  327. Emacs runs on a dumb terminal or in an Xterm window).
  328. @item Vi state
  329. This is the Vi command mode. Any of the Vi commands, such as @kbd{i, o, a},
  330. @dots{}, will take you to Insert state. All Vi commands may
  331. be used in this mode. Most Ex commands can also be used.
  332. For a full list of Ex commands supported by Viper, type
  333. @kbd{:} and then @key{TAB}. To get help on any issue, including the Ex
  334. commands, type @kbd{:help}. This will invoke Viper Info
  335. (if it is installed). Then typing @kbd{i} will prompt you for a topic to
  336. search in the index. Note: to search for Ex commands in the index, you
  337. should start them with a @kbd{:}, e.g., @kbd{:WW}.
  338. In Viper, Ex commands can be made to work on the current Emacs region.
  339. This is done by typing a digit argument before @kbd{:}.
  340. For instance, typing @kbd{1:} will prompt you with something like
  341. @emph{:123,135}, assuming that the current region starts at line 123 and
  342. ends at line 135. There is no need to type the line numbers, since Viper
  343. inserts them automatically in front of the Ex command.
  344. @item Insert state
  345. Insert state is the Vi insertion mode. @key{ESC} will take you back to
  346. Vi state. Insert state editing can be done, including auto-indentation. By
  347. default, Viper disables Emacs key bindings in Insert state.
  348. @item Replace state
  349. Commands like @kbd{cw} invoke the Replace state. When you cross the
  350. boundary of a replacement region (usually designated via a @samp{$} sign),
  351. it will automatically change to Insert state. You do not have to worry
  352. about it. The key bindings remain practically the same as in Insert
  353. state. If you type @key{ESC}, Viper will switch to Vi command mode, terminating the
  354. replacement state.
  355. @end table
  356. @cindex mode line
  357. The modes are indicated on the @dfn{mode line} as <E>, <I>, <V>, and <R>,
  358. so that the multiple modes do not confuse you. Most of your editing can be
  359. done in Vi and Insert states. Viper will try to make all new buffers be in Vi
  360. state, but sometimes they may come up in Emacs state. @kbd{C-z}
  361. will take you to Vi state in such a case. In some major modes, like Dired,
  362. Info, Gnus, etc., you should not switch to Vi state (and Viper will not
  363. attempt to do so) because these modes are not intended for text editing and
  364. many of the Vi keys have special meaning there. If you plan to read news,
  365. browse directories, read mail, etc., from Emacs (which you should start
  366. doing soon!), you should learn about the meaning of the various keys in
  367. those special modes (typing @kbd{C-h m} in a buffer provides
  368. help with key bindings for the major mode of that buffer).
  369. If you switch to Vi in Dired or similar modes, no harm is done. It is just
  370. that the special key bindings provided by those modes will be temporarily
  371. overshadowed by Viper's bindings. Switching back to Viper's Emacs state
  372. will revive the environment provided by the current major mode.
  373. States in Viper are orthogonal to Emacs major modes, such as C mode or Dired
  374. mode. You can turn Viper on and off for any Emacs state. When Viper is turned
  375. on, Vi state can be used to move around. In Insert state, the bindings for
  376. these modes can be accessed. For beginners (users at Viper levels 1 and 2),
  377. these bindings are suppressed in Insert state, so that new users are not
  378. confused by the Emacs states. Note that unless you allow Emacs bindings in
  379. Insert state, you cannot do many interesting things, like language
  380. sensitive editing. For the novice user (at Viper level 1), all major mode
  381. bindings are turned off in Vi state as well. This includes the bindings for
  382. key sequences that start with @kbd{C-c}, which practically means that all
  383. major mode bindings are unsupported. @xref{Customization}, to find out how
  384. to allow Emacs keys in Insert state.
  385. @menu
  386. * Emacs State:: This is the state you should learn more about when
  387. you get up to speed with Viper.
  388. * Vi State:: Vi commands are executed in this state.
  389. * Insert State:: You can enter text, and also can do sophisticated
  390. editing if you know enough Emacs commands.
  391. * Replace State:: Like Insert mode, but it is invoked via the
  392. replacement commands, such as cw, C, R, etc.
  393. @end menu
  394. @node Emacs State
  395. @subsection Emacs State
  396. @kindex @kbd{C-z}
  397. @cindex Emacs state
  398. You will be in this mode only by accident (hopefully). This is the state
  399. Emacs is normally in (imagine!!). Now leave it as soon as possible by
  400. typing @kbd{C-z}. Then you will be in Vi state (sigh of relief) :-).
  401. Emacs state is actually a Viperism to denote all the major and minor modes
  402. (@pxref{Emacs Preliminaries}) other than Viper that Emacs can be in. Emacs
  403. can have several modes, such as C mode for editing C programs, LaTeX mode
  404. for editing LaTeX documents, Dired for directory editing, etc. These are
  405. major modes, each with a different set of key-bindings. Viper states are
  406. orthogonal to these Emacs major modes. The presence of these language
  407. sensitive and other modes is a major win over Vi. @xref{Improvements over
  408. Vi}, for more.
  409. The bindings for these modes can be made available in the Viper Insert state
  410. as well as in Emacs state. Unless you specify your user level as 1 (a
  411. novice), all major mode key sequences that start with @kbd{C-x} and
  412. @kbd{C-c} are also available in Vi state. This is important because major
  413. modes designed for editing files, such as cc-mode or latex-mode, use key
  414. sequences that begin with @kbd{C-x} and @kbd{C-c}.
  415. There is also a key that lets you temporarily escape to Vi command state
  416. from the Insert state: typing @kbd{C-z} will let you execute a
  417. single Vi command while staying in Viper's Insert state.
  418. @node Vi State
  419. @subsection Vi State
  420. @cindex Vi state
  421. This is the Vi command mode. When Viper is in Vi state, you will see the sign
  422. <V> in the mode line. Most keys will work as in Vi. The notable
  423. exceptions are:
  424. @table @kbd
  425. @item C-x
  426. @kindex @kbd{C-x}
  427. @kbd{C-x} is used to invoke Emacs commands, mainly those that do window
  428. management. @kbd{C-x 2} will split a window, @kbd{C-x 0} will close a
  429. window. @kbd{C-x 1} will close all other windows. @kbd{C-xb} is used to
  430. switch buffers in a window, and @kbd{C-xo} to move through windows.
  431. These are about the only necessary keystrokes.
  432. For the rest, see the GNU Emacs Manual.
  433. @item C-c
  434. @kindex @kbd{C-c}
  435. For user levels 2 and higher, this key serves as a prefix key for the key
  436. sequences used by various major modes. For users at Viper level 1, @kbd{C-c}
  437. simply beeps.
  438. @item C-g and C-]
  439. @kindex @kbd{C-g}
  440. @kindex @kbd{C-]}
  441. These are the Emacs @samp{quit} keys.
  442. There will be cases where you will have to
  443. use @kbd{C-g} to quit. Similarly, @kbd{C-]} is used to exit
  444. @samp{Recursive Edits} in Emacs for which there is no comparable Vi
  445. functionality and no key-binding. Recursive edits are indicated by
  446. @samp{[]} brackets framing the modes on the mode line.
  447. @xref{Recursive Edit,Recursive
  448. Edit,Recursive Edit,emacs,The GNU Emacs Manual}.
  449. At user level 1, @kbd{C-g} is bound to @code{viper-info-on-file}
  450. function instead.
  451. @item C-\
  452. @kindex @kbd{C-\}
  453. @cindex Meta key
  454. Viper uses @key{ESC} as a switch between Insert and Vi states. Emacs uses
  455. @key{ESC} for Meta. The Meta key is very important in Emacs since many
  456. functions are accessible only via that key as @kbd{M-x function-name}.
  457. Therefore, we need to simulate it somehow. In Viper's Vi, Insert, and
  458. Replace states, the meta key is set to be @kbd{C-\}. Thus, to get
  459. @kbd{M-x}, you should type @kbd{C-\ x} (if the keyboard has no Meta key,
  460. which is rare these days).
  461. This works both in the Vi command state and in the Insert and Replace
  462. states. In Vi command state, you can also use @kbd{\ @key{ESC}} as the
  463. meta key.
  464. Note: Emacs binds @kbd{C-\} to a function that offers to change the
  465. keyboard input method in the multilingual environment. Viper overrides this
  466. binding. However, it is still possible to switch the input method by typing
  467. @kbd{\ C-\} in the Vi command state and @kbd{C-z \ C-\} in the Insert state.
  468. Or you can use the MULE menu in the menubar.
  469. @end table
  470. @noindent
  471. Other differences are mostly improvements. The ones you should know
  472. about are:
  473. @table @samp
  474. @item Undo
  475. @kindex @kbd{u}
  476. @kbd{u} will undo. Undo can be repeated by the @kbd{.} key. Undo itself
  477. can be undone. Another @kbd{u} will change the direction. The presence
  478. of repeatable undo means that @kbd{U}, undoing lines, is not very
  479. important. Therefore, @kbd{U} also calls @code{viper-undo}.
  480. @cindex multiple undo
  481. @cindex undo
  482. @item Counts
  483. Most commands, @kbd{~}, @kbd{[[}, @kbd{p}, @kbd{/}, @dots{}, etc., take counts.
  484. @comment ]] Just to balance parens
  485. @item Regexps
  486. Viper uses Emacs Regular Expressions for searches. These are a superset of
  487. Vi regular
  488. expressions, excepting the change-of-case escapes @samp{\u}, @samp{\L},
  489. @dots{}, etc. @xref{Regexps,,Syntax of Regular Expressions,emacs,The
  490. GNU Emacs Manual}, for details.
  491. Files specified to @kbd{:e} use @code{csh} regular expressions
  492. (globbing, wildcards, what have you).
  493. However, the function @code{viper-toggle-search-style}, bound to @kbd{C-c /},
  494. lets the user switch from search with regular expressions to plain vanilla
  495. search and vice versa. It also lets one switch from case-sensitive search
  496. to case-insensitive and back.
  497. @xref{Viper Specials}, for more details.
  498. @cindex regular expressions
  499. @cindex vanilla search
  500. @cindex case-sensitive search
  501. @cindex case-insensitive search
  502. @kindex @kbd{C-c /}
  503. @item Ex commands
  504. @cindex Ex commands
  505. The current working directory of a buffer is automatically inserted in the
  506. minibuffer if you type @kbd{:e} then space. Absolute filenames are
  507. required less often in Viper. For file names, Emacs uses a convention that
  508. is slightly different from other programs. It is designed to minimize the
  509. need for deleting file names that Emacs provides in its prompts. (This is
  510. usually convenient, but occasionally the prompt may suggest a wrong file
  511. name for you.) If you see a prompt @kbd{/usr/foo/} and you wish to edit the
  512. file @kbd{~/.file}, you don't have to erase the prompt. Instead, simply
  513. continue typing what you need. Emacs will interpret @kbd{/usr/foo/~/.file}
  514. correctly. Similarly, if the prompt is @kbd{~/foo/} and you need to get to
  515. @kbd{/bar/file}, keep typing. Emacs interprets @kbd{~/foo//bar/} as
  516. @kbd{/bar/file}, since when it sees @samp{//}, it understands that
  517. @kbd{~/foo/} is to be discarded.
  518. The command @kbd{:cd} will change the default directory for the
  519. current buffer. The command @kbd{:e} will interpret the
  520. filename argument in @code{csh}. @xref{Customization}, if you
  521. want to change the default shell.
  522. The command @kbd{:next} takes counts from
  523. @kbd{:args}, so that @kbd{:rew} is obsolete. Also, @kbd{:args} will show only
  524. the invisible files (i.e., those that are not currently seen in Emacs
  525. windows).
  526. When applicable, Ex commands support file completion and history. This
  527. means that by typing a partial file name and then @key{TAB}, Emacs will try
  528. to complete the name or it will offer a menu of possible completions.
  529. This works similarly to Tcsh and extends the behavior of Csh. While Emacs
  530. is waiting for a file name, you can type @kbd{M-p} to get the previous file
  531. name you typed. Repeatedly typing @kbd{M-p} and @kbd{M-n} will let you
  532. browse through the file history.
  533. Like file names, partially typed Ex commands can be completed by typing
  534. @key{TAB}, and Viper keeps the history of Ex commands. After typing
  535. @kbd{:}, you can browse through the previously entered Ex commands by
  536. typing @kbd{M-p} and @kbd{M-n}. Viper tries to rationalize when it puts Ex
  537. commands on the history list. For instance, if you typed @kbd{:w!@: foo},
  538. only @kbd{:w!} will be placed on the history list. This is because the
  539. last history element is the default that can be invoked simply by typing
  540. @kbd{: @key{RET}}. If @kbd{:w!@: foo} were placed on the list, it would be all to
  541. easy to override valuable data in another file. Reconstructing the full
  542. command, @kbd{:w!@: foo}, from the history is still not that hard, since Viper
  543. has a separate history for file names. By typing @kbd{: M-p}, you will get
  544. @kbd{:w!} in the minibuffer. Then, repeated @kbd{M-p} will get you through
  545. the file history, inserting one file name after another.
  546. In contrast to @kbd{:w!@: foo}, if the command were @kbd{:r foo}, the entire
  547. command will appear in the history list. This is because having @kbd{:r}
  548. alone as a default is meaningless, since this command requires a file
  549. argument.
  550. @end table
  551. @noindent
  552. As in Vi, Viper's destructive commands can be re-executed by typing
  553. a period (@kbd{.}).
  554. However, in addition, Viper keeps track of the history of such commands. This
  555. history can be perused by typing @kbd{C-c M-p} and @kbd{C-c M-n}.
  556. Having found the appropriate command, it can be then executed by typing
  557. a period.
  558. @xref{Improvements over Vi}, for more information.
  559. @node Insert State
  560. @subsection Insert State
  561. @cindex Insert state
  562. To avoid confusing the beginner (at Viper level 1 and 2), Viper makes only the
  563. standard Vi keys available in Insert state. The implication is that
  564. Emacs major modes cannot be used in Insert state.
  565. It is strongly recommended that as soon as you are comfortable, make the
  566. Emacs state bindings visible (by changing your user level to 3 or higher).
  567. @xref{Customization},
  568. to see how to do this.
  569. Once this is done, it is possible to do quite a bit of editing in
  570. Insert state. For instance, Emacs has a @dfn{yank} command, @kbd{C-y},
  571. which is similar to Vi's @kbd{p}. However, unlike @kbd{p}, @kbd{C-y} can be
  572. used in Insert state of Viper. Emacs also has a kill ring where it keeps
  573. pieces of text you deleted while editing buffers. The command @kbd{M-y} is
  574. used to delete the text previously put back by Emacs's @kbd{C-y} or by Vi's
  575. @kbd{p} command and reinsert text that was placed on the kill-ring earlier.
  576. This works both in Vi and Insert states.
  577. In Vi state, @kbd{M-y} is a much better alternative to the usual Vi's way
  578. of recovering the 10 previously deleted chunks of text. In Insert state,
  579. you can
  580. use this as follows. Suppose you deleted a piece of text and now you need
  581. to re-insert it while editing in Insert mode. The key @kbd{C-y} will put
  582. back the most recently deleted chunk. If this is not what you want, type
  583. @kbd{M-y} repeatedly and, hopefully, you will find the chunk you want.
  584. Finally, in Insert and Replace states, Viper provides the history of
  585. pieces of text inserted in previous insert or replace commands. These
  586. strings of text can be recovered by repeatedly typing @kbd{C-c M-p} or
  587. @kbd{C-c M-n} while in Insert or Replace state. (This feature is disabled
  588. in the minibuffer: the above keys are usually bound to other histories,
  589. which are more appropriate in the minibuffer.)
  590. @cindex Meta key
  591. You can call Meta functions from Insert state. As in Vi state, the Meta key
  592. is @kbd{C-\}. Thus @kbd{M-x} is typed as @kbd{C-\ x}.
  593. Other Emacs commands that are useful in Insert state are @kbd{C-e}
  594. and @kbd{C-a}, which move the cursor to the end and the beginning of the
  595. current line, respectively. You can also use @kbd{M-f} and @kbd{M-b},
  596. which move the cursor forward (or backward) one word.
  597. If your display has a Meta key, these functions are invoked by holding the
  598. Meta key and then typing @kbd{f} and @kbd{b}, respectively. On displays
  599. without the Meta key, these functions are invoked by typing
  600. @kbd{C-\ f} and @kbd{C-\ b} (@kbd{C-\} simulates the Meta key in Insert
  601. state, as explained above).
  602. The key @kbd{C-z} is sometimes also useful in Insert state: it allows you
  603. to execute a single command in Vi state without leaving the Insert state!
  604. For instance, @kbd{C-z d2w} will delete the next two words without leaving
  605. the Insert state.
  606. When Viper is in Insert state, you will see <I> in the mode line.
  607. @node Replace State
  608. @subsection Replace State
  609. @cindex Replace state
  610. This state is entered through Vi replacement commands, such as @kbd{C},
  611. @kbd{cw}, etc., or by typing @kbd{R}. In Replace state, Viper puts <R> in
  612. the mode line to let you know which state is in effect. If Replace state is
  613. entered through @kbd{R}, Viper stays in that state until the user hits
  614. @key{ESC}. If this state is entered via the other replacement commands,
  615. then Replace state is in effect until you hit @key{ESC} or until you cross
  616. the rightmost boundary of the replacement region. In the latter case, Viper
  617. changes its state from Replace to Insert (which you will notice by the
  618. change in the mode line).
  619. Since Viper runs under Emacs, it is possible to switch between buffers
  620. while in Replace state. You can also move the cursor using the arrow keys
  621. (even on dumb terminals!)@: and the mouse. Because of this freedom (which is
  622. unattainable in regular Vi), it is possible to take the cursor outside the
  623. replacement region. (This may be necessary for several reasons, including
  624. the need to enable text selection and region-setting with the mouse.)
  625. The issue then arises as to what to do when the user
  626. hits the @key{ESC} key. In Vi, this would cause the text between cursor and
  627. the end of the replacement region to be deleted. But what if, as is
  628. possible in Viper, the cursor is not inside the replacement region?
  629. To solve the problem, Viper keeps track of the last cursor position while it
  630. was still inside the replacement region. So, in the above situation, Viper
  631. would delete text between this position and the end of the replacement
  632. region.
  633. @node The Minibuffer
  634. @section The Minibuffer
  635. @cindex Minibuffer
  636. The minibuffer is where commands are entered in. Editing can be done
  637. by commands from Insert state, namely:
  638. @table @kbd
  639. @item C-h
  640. Backspace
  641. @item C-w
  642. Delete Word
  643. @item C-u
  644. Erase line
  645. @item C-v
  646. Quote the following character
  647. @item @key{RET}
  648. Execute command
  649. @item C-g and C-]
  650. Emacs quit and abort keys. These may be necessary. @xref{Vi State}, for an
  651. explanation.
  652. @item M-p and M-n
  653. These keys are bound to functions that peruse minibuffer history. The
  654. precise history to be perused depends on the context. It may be the history
  655. of search strings, Ex commands, file names, etc.
  656. @item C-s
  657. If the minibuffer is entered via the Viper search commands @kbd{/} or
  658. @kbd{?}, then this key inserts the last search string used by the
  659. Emacs incremental search command
  660. (which is bound to @kbd{C-s} everywhere except in this case).
  661. @end table
  662. Most of the Emacs keys are functional in the minibuffer. While in the
  663. minibuffer, Viper tries to make editing resemble Vi's behavior when the
  664. latter is waiting for the user to type an Ex command. In particular, you
  665. can use the regular Vi commands to edit the minibuffer. You can switch
  666. between the Vi state and Insert state at will, and even use the replace mode.
  667. Initially, the minibuffer comes up in Insert state.
  668. Some users prefer plain Emacs bindings in the minibuffer. To this end, set
  669. @code{viper-vi-style-in-minibuffer} to @code{nil} in
  670. your Viper customization file. @xref{Customization}, to learn how to do this.
  671. When the minibuffer changes Viper states, you will notice that the appearance
  672. of the text there changes as well. This is useful because the minibuffer
  673. has no mode line to tell which Vi state it is in.
  674. The appearance of the text in the minibuffer can be changed.
  675. @xref{Viper Specials}, for more details.
  676. @node Multiple Files in Viper
  677. @section Multiple Files in Viper
  678. @cindex multiple files
  679. @cindex managing multiple files
  680. Viper can edit multiple files. This means, for example that you never need
  681. to suffer through @code{No write since last change} errors.
  682. Some Viper elements are common over all the files.
  683. @table @samp
  684. @item Textmarkers
  685. @cindex markers
  686. @cindex textmarkers
  687. Textmarkers remember @emph{files and positions}.
  688. If you set marker @samp{a} in
  689. file @file{foo}, start editing file @file{bar} and type @kbd{'a}, then
  690. @emph{YOU WILL SWITCH TO FILE @file{foo}}. You can see the contents of a
  691. textmarker using the Viper command @kbd{[<a-z>} where <a-z> are the
  692. textmarkers, e.g., @kbd{[a} to view marker @samp{a} .
  693. @item Repeated Commands
  694. Command repetitions are common over files. Typing @kbd{!!} will repeat the
  695. last @kbd{!} command whichever file it was issued from.
  696. Typing @kbd{.} will repeat the last command from any file, and
  697. searches will repeat the last search. Ex commands can be repeated by typing
  698. @kbd{: @key{RET}}.
  699. Note: in some rare cases, that @kbd{: @key{RET}} may do something dangerous.
  700. However, usually its effect can be undone by typing @kbd{u}.
  701. @item Registers
  702. @cindex registers
  703. Registers are common to files. Also, text yanked with @kbd{y} can be
  704. put back (@kbd{p}) into any file. The Viper command @kbd{]<a-z>}, where <a-z> are
  705. the registers, can be used to look at the contents of a register, e.g.,
  706. type @kbd{]a} to view register @samp{a}.
  707. There is one difference in text deletion that you should be
  708. aware of. This difference comes from Emacs and was adopted in Viper
  709. because we find it very useful. In Vi, if you delete a line, say, and then
  710. another line, these two deletions are separated and are put back
  711. separately if you use the @samp{p} command. In Emacs (and Viper), successive
  712. series of deletions that are @emph{not interrupted} by other commands are
  713. lumped together, so the deleted text gets accumulated and can be put back
  714. as one chunk. If you want to break a sequence of deletions so that the
  715. newly deleted text could be put back separately from the previously deleted
  716. text, you should perform a non-deleting action, e.g., move the cursor one
  717. character in any direction.
  718. @item Absolute Filenames
  719. @cindex absolute file names
  720. The current directory name for a file is automatically prepended to the
  721. file name in any
  722. @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a
  723. current directory).
  724. This directory is inserted in the minibuffer once you type space after
  725. @kbd{:e, r}, etc. Viper also supports completion of file names and Ex
  726. commands (@key{TAB}), and it keeps track of
  727. command and file history (@kbd{M-p}, @kbd{M-n}).
  728. Absolute filenames are required less
  729. often in Viper.
  730. You should be aware that Emacs interprets @kbd{/foo/bar//bla} as
  731. @kbd{/bla} and @kbd{/foo/~/bar} as @kbd{~/bar}. This is designed to
  732. minimize the need for erasing file names that Emacs suggests in its
  733. prompts, if a suggested file name is not what you wanted.
  734. The command @kbd{:cd} will change the default directory for the
  735. current Emacs buffer. The Ex command @kbd{:e} will interpret the
  736. filename argument in @samp{csh}, by default. @xref{Customization}, if you
  737. want to change this.
  738. @end table
  739. @noindent
  740. Currently undisplayed files can be listed using the @kbd{:ar} command. The
  741. command @kbd{:n} can be given counts from the @kbd{:ar} list to switch to
  742. other files. For example, use @samp{:n3} to move to the third file in
  743. that list.
  744. @node Unimplemented Features
  745. @section Unimplemented Features
  746. Unimplemented features include:
  747. @itemize @bullet
  748. @item
  749. @kbd{:ab} and @kbd{:una} are not implemented, since
  750. @kbd{:ab} is considered obsolete, since Emacs has much
  751. more powerful facilities for defining abbreviations.
  752. @item
  753. @kbd{:set option?} is not implemented. The current
  754. @kbd{:set} can also be used to set Emacs variables.
  755. @item
  756. @kbd{:se list} requires modification of the display code for Emacs, so
  757. it is not implemented.
  758. A useful alternative is @code{cat -t -e file}. Unfortunately, it cannot
  759. be used directly inside Emacs, since Emacs will obdurately change @samp{^I}
  760. back to normal tabs.
  761. @end itemize
  762. @node Improvements over Vi
  763. @chapter Improvements over Vi
  764. Some common problems with Vi and Ex have been solved in Viper. This
  765. includes better implementation of existing commands, new commands, and
  766. the facilities provided by Emacs.
  767. @menu
  768. * Basics:: Basic Viper differences, Multi-file effects.
  769. * Undo and Backups:: Multiple undo, auto-save, backups and changes
  770. * History:: History for Ex and Vi commands.
  771. * Macros and Registers:: Keyboard Macros (extended ".")@: @@reg execution.
  772. * Completion:: Filename and Command Completion for Ex.
  773. * Improved Search:: Incremental Search and Buffer Content Search.
  774. * Abbreviation Facilities:: Normal Abbrevs, Templates, and Dynamic Abbrevs.
  775. * Movement and Markers:: Screen Editor movements, viewing textmarkers.
  776. * New Commands:: Commands that do not exist in Vi.
  777. * Useful Packages:: A Sampling of some Emacs packages, and things
  778. you should know about.
  779. @end menu
  780. @node Basics
  781. @section Basics
  782. The Vi command set is based on the idea of combining motion commands
  783. with other commands. The motion command is used as a text region
  784. specifier for other commands.
  785. We classify motion commands into @dfn{point commands} and
  786. @dfn{line commands}.
  787. @cindex point commands
  788. The point commands are:
  789. @quotation
  790. @kbd{h}, @kbd{l}, @kbd{0}, @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B},
  791. @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f},
  792. @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^}
  793. @end quotation
  794. @cindex line commands
  795. The line commands are:
  796. @quotation
  797. @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{},
  798. @kbd{@}}, @kbd{G}, @kbd{'}, @kbd{[[}, @kbd{]]}, @kbd{[]}
  799. @end quotation
  800. @cindex region
  801. @cindex region specification
  802. @cindex expanding (region)
  803. @cindex describing regions
  804. @cindex movement commands
  805. @noindent
  806. If a point command is given as an argument to a modifying command, the
  807. region determined by the point command will be affected by the modifying
  808. command. On the other hand, if a line command is given as an argument to a
  809. modifying command, the region determined by the line command will be
  810. enlarged so that it will become the smallest region properly containing the
  811. region and consisting of whole lines (we call this process @dfn{expanding
  812. the region}), and then the enlarged region will be affected by the modifying
  813. command.
  814. Text Deletion Commands (@pxref{Deleting Text}), Change commands
  815. (@pxref{Changing Text}), even Shell Commands (@pxref{Shell Commands})
  816. use these commands to describe a region of text to operate on.
  817. Thus, type @kbd{dw} to delete a word, @kbd{>@}} to shift a paragraph, or
  818. @kbd{!'afmt} to format a region from @samp{point} to textmarker
  819. @samp{a}.
  820. @cindex r and R region specifiers
  821. Viper adds the region specifiers @samp{r} and @samp{R}. Emacs has a
  822. special marker called @dfn{mark}. The text-area between the current cursor
  823. position @dfn{point} and the @dfn{mark} is called the @dfn{region}.
  824. @samp{r} specifies the raw region and @samp{R} is the expanded region
  825. (i.e., the minimal contiguous chunk of full lines that contains the raw
  826. region).
  827. @kbd{dr} will now delete the region, @kbd{>r} will shift it, etc.
  828. @kbd{r,R} are not motion commands, however. The special mark is set by
  829. @kbd{m.} and other commands. @xref{Marking}, for more info.
  830. Viper also adds counts to most commands for which it would make sense.
  831. In the Overview chapter, some Multiple File issues were discussed
  832. (@pxref{Multiple Files in Viper}). In addition to the files, Emacs has
  833. buffers. These can be seen in the @kbd{:args} list and switched using
  834. @kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or
  835. specify @code{(setq ex-cycle-through-non-files t)} in your
  836. Viper customization file. @xref{Customization}, for details.
  837. @node Undo and Backups
  838. @section Undo and Backups
  839. @cindex undo
  840. Viper provides multiple undo. The number of undo's and the size is limited
  841. by the machine. The Viper command @kbd{u} does an undo. Undo can be
  842. repeated by typing @kbd{.} (a period). Another @kbd{u} will undo the undo,
  843. and further
  844. @kbd{.} will repeat it. Typing @kbd{u} does the first undo, and changes the
  845. direction.
  846. @cindex backup files
  847. @cindex auto save
  848. Since the undo size is limited, Viper can create backup files and
  849. auto-save files. It will normally do this automatically. It is possible
  850. to have numbered backups, etc. For details, @pxref{Backup,,Backup and
  851. Auto-Save,emacs,The GNU Emacs Manual}.
  852. @comment [ balance parens
  853. @cindex viewing registers and markers
  854. @cindex registers
  855. @cindex markers
  856. @cindex textmarkers
  857. The results of the 9 previous changes are available in the 9 numeric
  858. registers, as in Vi. The extra goody is the ability to @emph{view} these
  859. registers, in addition to being able to access them through @kbd{p} and
  860. @kbd{M-y} (@xref{Insert State}, for details.)
  861. The Viper command @kbd{] register} will display the contents of any
  862. register, numeric or alphabetical. The related command @kbd{[ textmarker}
  863. will show the text around the textmarker. @samp{register} and @samp{textmarker}
  864. can be any letters from a through z.
  865. @comment ] balance parens
  866. @node History
  867. @section History
  868. @cindex history
  869. @cindex Minibuffer
  870. History is provided for Ex commands, Vi searches, file names, pieces of
  871. text inserted in earlier commands that use Insert or Replace state, and for
  872. destructive commands in Vi state. These are
  873. useful for fixing those small typos that screw up searches and @kbd{:s},
  874. and for eliminating routine associated with repeated typing of file names
  875. or pieces of text that need to be inserted frequently.
  876. At the @kbd{:} or @kbd{/} prompts in the minibuffer, you can do the following:
  877. @table @kbd
  878. @item M-p and M-n
  879. To move to previous and next history items. This causes the history
  880. items to appear on the command line, where you can edit them, or
  881. simply type Return to execute.
  882. @item M-r and M-s
  883. To search backward and forward through the history.
  884. @item @key{RET}
  885. Type @key{RET} to accept a default (which is displayed in the prompt).
  886. @end table
  887. The history of insertions can be perused by
  888. typing @kbd{C-c M-p} and @kbd{C-c M-n} while in Insert or Replace state.
  889. The history of destructive Vi commands can be perused via the same keys
  890. when Viper is in Vi state. @xref{Viper Specials}, for details.
  891. All Ex commands have a file history. For instance, typing @kbd{:e}, space
  892. and then @kbd{M-p} will bring up the name of the previously typed file
  893. name. Repeatedly typing @kbd{M-p}, @kbd{M-n}, etc., will let you browse
  894. through the file history.
  895. Similarly, commands that have to do with switching buffers
  896. have a buffer history, and commands that expect strings or regular
  897. expressions keep a history on those items.
  898. @node Macros and Registers
  899. @section Macros and Registers
  900. @cindex keyboard macros
  901. @cindex macros
  902. @cindex registers
  903. @cindex register execution
  904. Viper facilitates the use of Emacs-style keyboard macros. @kbd{@@#} will
  905. start a macro definition. As you type, the commands will be executed, and
  906. remembered (This is called ``learn mode'' in some editors.)
  907. @kbd{@@register} will complete the macro, putting it into @samp{register},
  908. where @samp{register} is any character from @samp{a} through @samp{z}. Then
  909. you can execute this macro using @kbd{@@register}. It is, of course,
  910. possible to yank some text into a register and execute it using
  911. @kbd{@@register}. Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@C-j} will
  912. execute the last macro that was executed using @kbd{@@register}.
  913. Viper will automatically lowercase the register, so that pressing the
  914. @kbd{SHIFT} key for @kbd{@@} will not create problems. This is for
  915. @kbd{@@} macros and @kbd{"p} @emph{only}. In the case of @kbd{y},
  916. @kbd{"Ayy} will append to @emph{register a}. For @kbd{[,],',`}, it
  917. is an error to use a Uppercase register name.
  918. @comment [ balance parens
  919. @cindex viewing registers and markers
  920. The contents of a register can be seen by @kbd{]register}. (@kbd{[textmarker}
  921. will show the contents of a textmarker).
  922. @comment ] balance parens
  923. @cindex last keyboard macro
  924. The last keyboard macro can also be executed using
  925. @kbd{*}, and it can be yanked into a register using @kbd{@@!register}.
  926. This is useful for Emacs style keyboard macros defined using @kbd{C-x(}
  927. and @kbd{C-x)}. Emacs keyboard macros have more capabilities.
  928. @xref{Keyboard Macros,,Keyboard Macros,emacs, The GNU Emacs Manual}, for
  929. details.
  930. Keyboard Macros allow an interesting form of Query-Replace:
  931. @kbd{/pattern} or @kbd{n} to go to the next pattern (the query), followed by a
  932. Keyboard Macro execution @kbd{@@@@} (the replace).
  933. Viper also provides Vi-style macros. @xref{Vi Macros}, for details.
  934. @node Completion
  935. @section Completion
  936. @cindex completion
  937. Completion is done when you type @key{TAB}. The Emacs completer does not
  938. grok wildcards in file names. Once you type a wildcard, the completer will
  939. no longer work for that file name. Remember that Emacs interprets a file name
  940. of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as
  941. @kbd{~/bar}.
  942. @node Improved Search
  943. @section Improved Search
  944. @cindex buffer search
  945. @cindex word search
  946. Viper provides buffer search, the ability to search the buffer for a region
  947. under the cursor. You have to turn this on in your Viper customization file
  948. either by calling
  949. @example
  950. (viper-buffer-search-enable)
  951. @end example
  952. @noindent
  953. or by setting @code{viper-buffer-search-char} to, say, @kbd{f3}:
  954. @example
  955. (setq viper-buffer-search-char ?g)
  956. @end example
  957. @noindent
  958. If the user calls @code{viper-buffer-search-enable} explicitly (the first
  959. method), then @code{viper-buffer-search-char} will be set to @kbd{g}.
  960. Regardless of how this feature is enabled, the key
  961. @code{viper-buffer-search-char} will take movement commands, like
  962. @kbd{w,/,e}, to find a region and then search for the contents of that
  963. region. This command is very useful for searching for variable names, etc.,
  964. in a program. The search can be repeated by @kbd{n} or reversed by @kbd{N}.
  965. @cindex incremental search
  966. Emacs provides incremental search. As you type the string in, the
  967. cursor will move to the next match. You can snarf words from the buffer
  968. as you go along. Incremental Search is normally bound to @kbd{C-s} and
  969. @kbd{C-r}. @xref{Customization}, to find out how to change the bindings
  970. of @kbd{C-r or C-s}.
  971. For details, @pxref{Incremental Search,,Incremental
  972. Search,emacs,The GNU Emacs Manual}.
  973. @cindex query replace
  974. Viper also provides a query replace function that prompts through the
  975. minibuffer. It is invoked by the @kbd{Q} key in Vi state.
  976. @cindex mouse search
  977. On a window display, Viper supports mouse search, i.e., you can search for a
  978. word by clicking on it. @xref{Viper Specials}, for details.
  979. Finally, on a window display, Viper highlights search patterns as it finds
  980. them. This is done through what is known as @emph{faces} in Emacs. The
  981. variable that controls how search patterns are highlighted is
  982. @code{viper-search-face}. If you don't want any highlighting at all, put
  983. @example
  984. (copy-face 'default 'viper-search-face)
  985. @end example
  986. @vindex @code{viper-search-face}
  987. @noindent
  988. in your Viper customization file. If you want to change how patterns are
  989. highlighted, you will have to change @code{viper-search-face} to your liking.
  990. The easiest way to do this is to use Emacs customization widget, which is
  991. accessible from the menubar. Viper customization group is located under the
  992. @emph{Emulations} customization group, which in turn is under the
  993. @emph{Editing} group (or simply by typing @kbd{:customize}). All Viper
  994. faces are grouped together under Viper's
  995. @emph{Highlighting} group.
  996. Try it: it is really simple!
  997. @node Abbreviation Facilities
  998. @section Abbreviation Facilities
  999. @cindex abbrevs
  1000. It is possible in Emacs to define abbrevs based on the contents of the
  1001. buffer.
  1002. Sophisticated templates can be defined using the Emacs abbreviation
  1003. facilities. @xref{Abbrevs,,Abbreviations,emacs,The GNU Emacs Manual}, for
  1004. details.
  1005. @cindex dynamic abbrevs
  1006. Emacs also provides Dynamic Abbreviations. Given a partial word, Emacs
  1007. will search the buffer to find an extension for this word. For instance,
  1008. one can type @samp{Abbreviations} by typing @samp{A}, followed by a keystroke
  1009. that completed the @samp{A} to @samp{Abbreviations}. Repeated typing
  1010. will search further back in the buffer, so that one could get
  1011. @samp{Abbrevs} by repeating the
  1012. keystroke, which appears earlier in the text. Emacs binds this to
  1013. @kbd{@key{ESC} /}, so you will have to find a key and bind the function
  1014. @code{dabbrev-expand} to that key.
  1015. Facilities like this make Vi's @kbd{:ab} command obsolete.
  1016. @node Movement and Markers
  1017. @section Movement and Markers
  1018. @cindex Ex style motion
  1019. @cindex line editor motion
  1020. Viper can be set free from the line-limited movements in Vi, such as @kbd{l}
  1021. refusing to move beyond the line, @key{ESC} moving one character back,
  1022. etc. These derive from Ex, which is a line editor. If your
  1023. Viper customization file contains
  1024. @example
  1025. @code{(setq viper-ex-style-motion nil)}
  1026. @end example
  1027. @noindent
  1028. the motion will be a true screen editor motion. One thing you must then
  1029. watch out for is that it is possible to be on the end-of-line character.
  1030. The keys @kbd{x} and @kbd{%} will still work correctly, i.e., as if they
  1031. were on the last character.
  1032. @vindex @code{viper-syntax-preference}
  1033. @cindex syntax table
  1034. The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated
  1035. deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to
  1036. understand Emacs syntax tables. If the variable
  1037. @code{viper-syntax-preference} is set to @code{strict-vi} then
  1038. the meaning of @emph{word} is the same as in
  1039. Vi. However, if the value is @code{reformed-vi} (the default) then the
  1040. alphanumeric symbols will be those specified by the current Emacs syntax
  1041. table (which may be different for different major modes) plus the
  1042. underscore symbol @kbd{_}, minus some non-word symbols, like '.;,|, etc.
  1043. Both @code{strict-vi} and @code{reformed-vi} work close to Vi in
  1044. traditional cases, but @code{reformed-vi} does a better job when editing
  1045. text in non-Latin alphabets.
  1046. The user can also specify the value @code{emacs}, which would
  1047. make Viper use exactly the Emacs notion of word. In particular, the
  1048. underscore may not be part of a word. Finally, if
  1049. @code{viper-syntax-preference} is set to @code{extended}, Viper words would
  1050. consist of characters that are classified as alphanumeric @emph{or} as
  1051. parts of symbols. This is convenient for writing programs and in many other
  1052. situations.
  1053. @code{viper-syntax-preference} is a local variable, so it can have different
  1054. values for different major modes. For instance, in programming modes it can
  1055. have the value @code{extended}. In text modes where words contain special
  1056. characters, such as European (non-English) letters, Cyrillic letters, etc.,
  1057. the value can be @code{reformed-vi} or @code{emacs}.
  1058. Changes to @code{viper-syntax-preference} should be done in the hooks to
  1059. various major modes by executing @code{viper-set-syntax-preference} as in
  1060. the following example:
  1061. @example
  1062. (viper-set-syntax-preference nil "emacs")
  1063. @end example
  1064. @findex @code{viper-set-syntax-preference}
  1065. The above discussion of the meaning of Viper's words concerns only Viper's
  1066. movement commands. In regular expressions, words remain the same as in
  1067. Emacs. That is, the expressions @code{\w}, @code{\>}, @code{\<}, etc., use
  1068. Emacs's idea of what is a word, and they don't look into the value of
  1069. variable @code{viper-syntax-preference}. This is because Viper doesn't change
  1070. syntax tables in fear of upsetting the various major modes that set these
  1071. tables.
  1072. @cindex textmarkers
  1073. Textmarkers in Viper remember the file and the position, so that you can
  1074. switch files by simply doing @kbd{'a}. If you set up a regimen for using
  1075. Textmarkers, this is very useful. Contents of textmarkers can be viewed
  1076. by @kbd{[marker}. (Contents of registers can be viewed by @kbd{]register}).
  1077. @node New Commands
  1078. @section New Commands
  1079. These commands have no Vi analogs.
  1080. @table @kbd
  1081. @item C-x, C-c
  1082. @kindex @kbd{C-x}
  1083. @kindex @kbd{C-c}
  1084. These two keys invoke many important Emacs functions. For example, if you
  1085. hit @kbd{C-x} followed by @kbd{2}, then the current window will be split
  1086. into 2. Except for novice users, @kbd{C-c} is also set to execute an Emacs
  1087. command from the current major mode. @key{ESC} will do the same, if you
  1088. configure @key{ESC} as Meta by setting @code{viper-no-multiple-ESC} to
  1089. @code{nil} in your Viper customization file. @xref{Customization}.
  1090. @kbd{C-\} in Insert, Replace, or Vi states will make Emacs think
  1091. @kbd{Meta} has been hit.
  1092. @item \
  1093. @kindex @kbd{\}
  1094. Escape to Emacs to execute a single Emacs command. For instance,
  1095. @kbd{\ @key{ESC}} will act like a Meta key.
  1096. @item Q
  1097. @kindex @kbd{Q}
  1098. @cindex query replace
  1099. @kbd{Q} is for query replace. By default,
  1100. each string to be replaced is treated as a regular expression. You can use
  1101. @code{(setq viper-re-query-replace nil)} in your @file{.emacs} file to
  1102. turn this off. (For normal searches, @kbd{:se nomagic} will work. Note
  1103. that @kbd{:se nomagic} turns Regexps off completely, unlike Vi).
  1104. @item v
  1105. @itemx V
  1106. @itemx C-v
  1107. @kindex @kbd{v}
  1108. @kindex @kbd{V}
  1109. @kindex @kbd{C-v}
  1110. These keys are used to visit files. @kbd{v} will switch to a buffer
  1111. visiting file whose name can be entered in the minibuffer. @kbd{V} is
  1112. similar, but will use a window different from the current window.
  1113. @kbd{C-v} is like @kbd{V}, except that a new frame (X window) will be used
  1114. instead of a new Emacs window.
  1115. @item #
  1116. @kindex @kbd{#}
  1117. If followed by a certain character @var{ch}, it becomes an operator whose
  1118. argument is the region determined by the motion command that follows
  1119. (indicated as <move>).
  1120. Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q}, and
  1121. @kbd{s}. For instance, @kbd{#qr} will prompt you for a string and then
  1122. prepend this string to each line in the buffer.
  1123. @item # c
  1124. @kindex @kbd{#c<move>}
  1125. @cindex changing case
  1126. Change upper-case characters in the region to lower-case
  1127. (@code{downcase-region}).
  1128. Emacs command @kbd{M-l} does the same for words.
  1129. @item # C
  1130. @kindex @kbd{#C<move>}
  1131. Change lower-case characters in the region to upper-case. For instance,
  1132. @kbd{# C 3 w} will capitalize 3 words from the current point
  1133. (@code{upcase-region}).
  1134. Emacs command @kbd{M-u} does the same for words.
  1135. @item # g
  1136. @kindex @kbd{#g<move>}
  1137. Execute last keyboard macro for each line in the region
  1138. (@code{viper-global-execute}).
  1139. @item # q
  1140. @kindex @kbd{#q<move>}
  1141. Insert specified string at the beginning of each line in the region
  1142. (@code{viper-quote-region}). The default string is composed of the comment
  1143. character(s) appropriate for the current major mode.
  1144. @item # s
  1145. @kindex @kbd{#s<move>}
  1146. Check spelling of words in the region (@code{spell-region}).
  1147. The function used for spelling is determined from the variable
  1148. @code{viper-spell-function}.
  1149. @vindex @code{viper-spell-function}
  1150. @item *
  1151. @kindex @kbd{*}
  1152. Call last keyboard macro.
  1153. @item m .
  1154. Set mark at point and push old mark off the ring
  1155. @item m<
  1156. @item m>
  1157. Set mark at beginning and end of buffer, respectively.
  1158. @item m,
  1159. Jump to mark and pop mark off the ring. @xref{Mark,,Mark,emacs,The GNU
  1160. Emacs Manual}, for more info.
  1161. @item ] register
  1162. @kindex @kbd{]<a-z>}
  1163. View contents of register
  1164. @item [ textmarker
  1165. @kindex @kbd{[<a-z>}
  1166. View filename and position of textmarker
  1167. @item @@#
  1168. @item @@register
  1169. @item @@!
  1170. @kindex @kbd{@@#}
  1171. @kindex @kbd{@@<a-z>}
  1172. @kindex @kbd{@@!}
  1173. @cindex keyboard macros
  1174. @cindex register execution
  1175. Begin/end keyboard macro. @@register has a different meaning when used after
  1176. a @kbd{@@#}. @xref{Macros and Registers}, for details
  1177. @item []
  1178. @kindex @kbd{[]}
  1179. Go to end of heading.
  1180. @item g <@emph{movement command}>
  1181. Search buffer for text delimited by movement command. The canonical
  1182. example is @kbd{gw} to search for the word under the cursor.
  1183. @xref{Improved Search}, for details.
  1184. @item C-g and C-]
  1185. @kindex @kbd{C-g}
  1186. @kindex @kbd{C-]}
  1187. Quit and Abort Recursive edit. These may be necessary on occasion.
  1188. @xref{Vi State}, for a reason.
  1189. @item C-c C-g
  1190. @kindex @kbd{C-c C-g}
  1191. Hitting @kbd{C-c} followed by @kbd{C-g} will display the information on the
  1192. current buffer. This is the same as hitting @kbd{C-g} in Vi, but, as
  1193. explained above, @kbd{C-g} is needed for other purposes in Emacs.
  1194. @item C-c /
  1195. @kindex @kbd{C-c /}
  1196. Without a prefix argument, this command toggles
  1197. case-sensitive/case-insensitive search modes and plain vanilla/regular
  1198. expression search. With the prefix argument 1, i.e.,
  1199. @kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2,
  1200. toggles plain vanilla search and search using
  1201. regular expressions. @xref{Viper Specials}, for alternative ways to invoke
  1202. this function.
  1203. @cindex vanilla search
  1204. @cindex case-sensitive search
  1205. @cindex case-insensitive search
  1206. @item M-p and M-n
  1207. @kindex @kbd{M-p}
  1208. @kindex @kbd{M-n}
  1209. In the minibuffer, these commands navigate through the minibuffer
  1210. histories, such as the history of search strings, Ex commands, etc.
  1211. @item C-s
  1212. @kindex @kbd{C-s}
  1213. If the minibuffer is entered via a Viper search commands @kbd{/} or @kbd{?},
  1214. then typing this key inserts the last search string used by the
  1215. Emacs incremental search command (that is bound to @kbd{C-s} everywhere
  1216. except in this case).
  1217. @item C-c M-p and C-c M-n
  1218. @kindex @kbd{C-c M-p}
  1219. @kindex @kbd{C-c M-n}
  1220. @cindex Insertion history
  1221. @cindex Insertion ring
  1222. @cindex Command history
  1223. @cindex Command ring
  1224. In Insert or Replace state, these commands let the user
  1225. peruse the history of insertion strings used in previous insert or replace
  1226. commands. Try to hit @kbd{C-c M-p} or @kbd{C-c M-n} repeatedly and see what
  1227. happens. @xref{Viper Specials}, for more.
  1228. In Vi state, these commands let the user peruse the history of Vi-style
  1229. destructive commands, such as @kbd{dw}, @kbd{J}, @kbd{a}, etc.
  1230. By repeatedly typing @kbd{C-c M-p} or @kbd{C-c M-n} you will cycle Viper
  1231. through the recent history of Vi commands, displaying the commands one by
  1232. one. Once an appropriate command is found, it can be executed by
  1233. typing a period.
  1234. Since typing @kbd{C-c M-p} is tedious, it is more convenient to bind an
  1235. appropriate function to a function key on the keyboard and use that key.
  1236. @xref{Viper Specials}, for details.
  1237. @item Ex commands
  1238. @findex @kbd{Ex args}
  1239. @findex @kbd{Ex n}
  1240. @findex @kbd{Ex pwd}
  1241. @findex @kbd{Ex pre}
  1242. The commands @kbd{:args}, @kbd{:next}, @kbd{:pre} behave
  1243. differently. @kbd{:pwd} exists to get current directory.
  1244. The commands @kbd{:b} and @kbd{:B} switch buffers around. @xref{File and
  1245. Buffer Handling}, for details.
  1246. There are also the new commands @kbd{:RelatedFile} and
  1247. @kbd{PreviousRelatedFile} (which abbreviate to @kbd{R} and @kbd{P},
  1248. respectively. @xref{Viper Specials}, for details.
  1249. @findex @kbd{Ex RelatedFile}
  1250. @findex @kbd{Ex PreviousRelatedFile}
  1251. @end table
  1252. Apart from the new commands, many old commands have been enhanced. Most
  1253. notably, Vi style macros are much more powerful in Viper than in Vi. @xref{Vi
  1254. Macros}, for details.
  1255. @node Useful Packages
  1256. @section Useful Packages
  1257. Some Emacs packages are mentioned here as an aid to the new Viper user, to
  1258. indicate what Viper is capable of.
  1259. A vast number comes with the standard Emacs distribution, and many more exist
  1260. on the net and on the archives.
  1261. This manual also mentions some Emacs features a new user
  1262. should know about. The details of these are found in the GNU Emacs
  1263. Manual.
  1264. The features first. For details, look up the Emacs Manual.
  1265. @table @samp
  1266. @item Make
  1267. @cindex make
  1268. @cindex compiling
  1269. Makes and Compiles can be done from the editor. Error messages will be
  1270. parsed and you can move to the error lines.
  1271. @item Shell
  1272. @cindex shell
  1273. @cindex interactive shell
  1274. You can talk to Shells from inside the editor. Your entire shell session
  1275. can be treated as a file.
  1276. @item Mail
  1277. @cindex email
  1278. @cindex mail
  1279. Mail can be read from and sent within the editor. Several sophisticated
  1280. packages exist.
  1281. @item Language Sensitive Editing
  1282. Editing modes are written for most computer languages in existence. By
  1283. controlling indentation, they catch punctuation errors.
  1284. @end table
  1285. The packages, below, represents a drop in the sea of special-purpose
  1286. packages that come with standard distribution of Emacs.
  1287. @table @samp
  1288. @item Transparent FTP
  1289. @cindex transparent ftp
  1290. @pindex ange-ftp.el
  1291. @code{ange-ftp.el} can ftp from the editor to files on other machines
  1292. transparent to the user.
  1293. @item RCS Interfaces
  1294. @cindex version maintenance
  1295. @cindex RCS
  1296. @pindex vc.el
  1297. @code{vc.el} for doing RCS commands from inside the editor
  1298. @item Directory Editor
  1299. @cindex dired
  1300. @pindex dired.el
  1301. @code{dired.el} for editing contents of directories and for navigating in
  1302. the file system.
  1303. @item Syntactic Highlighting
  1304. @cindex font-lock
  1305. @pindex font-lock.el
  1306. @code{font-lock.el} for automatic highlighting various parts of a buffer
  1307. using different fonts and colors.
  1308. @item Saving Emacs Configuration
  1309. @cindex desktop
  1310. @pindex desktop.el
  1311. @code{desktop.el} for saving/restoring configuration on Emacs exit/startup.
  1312. @item Spell Checker
  1313. @cindex ispell
  1314. @pindex ispell.el
  1315. @code{ispell.el} for spell checking the buffer, words, regions, etc.
  1316. @item File and Buffer Comparison
  1317. @cindex ediff
  1318. @pindex ediff.el
  1319. @code{ediff.el} for finding differences between files and for applying
  1320. patches.
  1321. @end table
  1322. @noindent
  1323. Emacs Lisp archives exist on
  1324. @samp{archive.cis.ohio-state.edu}
  1325. and @samp{wuarchive.wustl.edu}
  1326. @node Customization
  1327. @chapter Customization
  1328. @cindex customization
  1329. Customization can be done in 2 ways.
  1330. @itemize @bullet
  1331. @item
  1332. @cindex initialization
  1333. @cindex .viper
  1334. Elisp code in a @file{~/.emacs.d/viper} (or @file{~/.viper}) file.
  1335. Viper loads this file just before it does the binding for mode hooks.
  1336. This is recommended for experts only.
  1337. @item
  1338. @cindex .emacs
  1339. Elisp code in your @file{.emacs} file before and after the @code{(require
  1340. 'viper)} line. This method is @emph{not} recommended, unless you know what
  1341. you are doing. Only two variables, @code{viper-mode} and
  1342. @code{viper-custom-file-name}, are supposed to be customized in @file{.emacs},
  1343. prior to loading Viper (i.e., prior to @code{(require 'viper)} command.
  1344. @item
  1345. @cindex Ex customize
  1346. By executing the @kbd{:customize} Ex command. This takes you to the Emacs
  1347. customization widget, which lets you change the values of Viper
  1348. customizable variables easily. This method is good for novice and
  1349. experts alike. The customization code in the form of Lisp commands will be
  1350. placed in @file{~/.emacs} or some other customization file depending on the
  1351. version of Emacs that you use. Still, it is recommended to separate
  1352. Viper-related customization produced by the Emacs customization widget
  1353. and keep it in your Viper customization file.
  1354. Some advanced customization cannot be accomplished this way, however, and
  1355. has to be done in Emacs Lisp in your Viper customization file. For the common
  1356. cases, examples are provided that you can use directly.
  1357. @end itemize
  1358. @menu
  1359. * Rudimentary Changes:: Simple constant definitions.
  1360. * Key Bindings:: Enabling Emacs Keys, Rebinding keys, etc.
  1361. * Packages that Change Keymaps:: How to deal with such beasts.
  1362. * Viper Specials:: Special Viper commands.
  1363. * Vi Macros:: How to do Vi style macros.
  1364. @end menu
  1365. @node Rudimentary Changes
  1366. @section Rudimentary Changes
  1367. @cindex setting variables
  1368. @cindex variables for customization
  1369. @findex @kbd{Ex set}
  1370. An easy way to customize Viper is to change the values of constants used in
  1371. Viper. Here is the list of the constants used in Viper and their default
  1372. values. The corresponding :se command is also indicated. (The symbols
  1373. @code{t} and @code{nil} represent ``true'' and ``false'' in Lisp).
  1374. Viper supports both the abbreviated Vi variable names and their full
  1375. names. Variable completion is done on full names only. @key{TAB} and
  1376. @key{SPC} complete
  1377. variable names. Typing @kbd{=} will complete the name and then will prompt for
  1378. a value, if applicable. For instance, @kbd{:se au @key{SPC}} will complete the
  1379. command to @kbd{:set autoindent}; @kbd{:se ta @key{SPC}} will complete the command
  1380. and prompt further like this: @kbd{:set tabstop = }.
  1381. However, typing @kbd{:se ts @key{SPC}} will produce a ``No match'' message
  1382. because @kbd{ts} is an abbreviation for @kbd{tabstop} and Viper supports
  1383. completion on full names only. However, you can still hit @key{RET}
  1384. or @kbd{=}, which will complete the command like this: @kbd{:set ts = } and
  1385. Viper will be waiting for you to type a value for the tabstop variable.
  1386. To get the full list of Vi variables, type @kbd{:se @key{SPC} @key{TAB}}.
  1387. @table @code
  1388. @item viper-auto-indent nil
  1389. @itemx :se ai (:se autoindent)
  1390. @itemx :se ai-g (:se autoindent-global)
  1391. If @code{t}, enable auto indentation.
  1392. by @key{RET}, @kbd{o} or @kbd{O} command.
  1393. @code{viper-auto-indent} is a local variable. To change the value globally, use
  1394. @code{setq-default}. It may be useful for certain major modes to have their
  1395. own values of @code{viper-auto-indent}. This can be achieved by using
  1396. @code{setq} to change the local value of this variable in the hooks to the
  1397. appropriate major modes.
  1398. @kbd{:se ai} changes the value of @code{viper-auto-indent} in the current
  1399. buffer only; @kbd{:se ai-g} does the same globally.
  1400. @item viper-electric-mode t
  1401. If not @code{nil}, auto-indentation becomes electric, which means that
  1402. @key{RET}, @kbd{O}, and @kbd{o} indent cursor according to the current
  1403. major mode. In the future, this variable may control additional electric
  1404. features.
  1405. This is a local variable: @code{setq} changes the value of this variable
  1406. in the current buffer only. Use @code{setq-default} to change the value in
  1407. all buffers.
  1408. @item viper-case-fold-search nil
  1409. @itemx :se ic (:se ignorecase)
  1410. If not @code{nil}, search ignores cases.
  1411. This can also be toggled by quickly hitting @kbd{/} twice.
  1412. @item viper-re-search nil
  1413. @itemx :se magic
  1414. If not @code{nil}, search will use regular expressions; if @code{nil} then
  1415. use vanilla search.
  1416. This behavior can also be toggled by quickly hitting @kbd{/} trice.
  1417. @item buffer-read-only
  1418. @itemx :se ro (:se readonly)
  1419. Set current buffer to read only. To change globally put
  1420. @code{(setq-default buffer-read-only t)} in your @file{.emacs} file.
  1421. @item blink-matching-paren t
  1422. @itemx :se sm (:se showmatch)
  1423. Show matching parens by blinking cursor.
  1424. @item tab-width t (default setting via @code{setq-default})
  1425. @itemx :se ts=value (:se tabstop=value)
  1426. @itemx :se ts-g=value (:se tabstop-global=value)
  1427. @code{tab-width} is a local variable that controls the width of the tab stops.
  1428. To change the value globally, use @code{setq-default}; for local settings,
  1429. use @code{setq}.
  1430. The command @kbd{:se ts}
  1431. sets the tab width in the current
  1432. buffer only; it has no effect on other buffers.
  1433. The command @kbd{:se ts-g} sets tab width globally,
  1434. for all buffers where the tab is not yet set locally,
  1435. including the new buffers.
  1436. Note that typing @key{TAB} normally
  1437. doesn't insert the tab, since this key is usually bound to
  1438. a text-formatting function, @code{indent-for-tab-command} (which facilitates
  1439. programming and document writing). Instead, the tab is inserted via the
  1440. command @code{viper-insert-tab}, which is bound to @kbd{S-tab} (shift + tab).
  1441. On some non-windowing terminals, Shift doesn't modify the @key{TAB} key, so
  1442. @kbd{S-tab} behaves as if it were @key{TAB}. In such a case, you will have
  1443. to bind @code{viper-insert-tab} to some other convenient key.
  1444. @item viper-shift-width 8
  1445. @itemx :se sw=value (:se shiftwidth=value)
  1446. The number of columns shifted by @kbd{>} and @kbd{<} commands.
  1447. @item viper-search-wrap-around t
  1448. @itemx :se ws (:se wrapscan)
  1449. If not @code{nil}, search wraps around the end/beginning of buffer.
  1450. @item viper-search-scroll-threshold 2
  1451. If search lands within this many lines of the window top or bottom, the
  1452. window will be scrolled up or down by about 1/7-th of its size, to reveal
  1453. the context. If the value is negative, don't scroll.
  1454. @item viper-tags-file-name "TAGS"
  1455. The name of the file used as the tag table.
  1456. @item viper-re-query-replace nil
  1457. If not @code{nil}, use reg-exp replace in query replace.
  1458. @item viper-want-ctl-h-help nil
  1459. If not @code{nil}, @kbd{C-h} is bound to @code{help-command};
  1460. otherwise, @kbd{C-h} is bound as usual in Vi.
  1461. @item viper-vi-style-in-minibuffer t
  1462. If not @code{nil}, Viper provides a high degree of compatibility with Vi
  1463. insert mode when you type text in the minibuffer; if @code{nil}, typing in
  1464. the minibuffer feels like plain Emacs.
  1465. @item viper-no-multiple-ESC t
  1466. If you set this to @code{nil}, you can use @key{ESC} as Meta in Vi state.
  1467. Normally, this is not necessary, since graphical displays have separate
  1468. Meta keys (usually on each side of the space bar). On a dumb terminal, Viper
  1469. sets this variable to @code{twice}, which is almost like @code{nil}, except
  1470. that double @key{ESC} beeps. This, too, lets @key{ESC} to be used as a Meta.
  1471. @item viper-fast-keyseq-timeout 200
  1472. Key sequences separated by this many milliseconds are treated as Vi-style
  1473. keyboard macros. If the key sequence is defined as such a macro, it will be
  1474. executed. Otherwise, it is processed as an ordinary sequence of typed keys.
  1475. Setting this variable too high may slow down your typing. Setting it too
  1476. low may make it hard to type macros quickly enough.
  1477. @item viper-ex-style-motion t
  1478. Set this to @code{nil}, if you want @kbd{l,h} to cross
  1479. lines, etc. @xref{Movement and Markers}, for more info.
  1480. @item viper-ex-style-editing t
  1481. Set this to @code{nil}, if you want
  1482. @kbd{C-h} and @key{DEL} to not stop
  1483. at the beginning of a line in Insert state, @key{X} and @key{x} to delete
  1484. characters across lines in Vi command state, etc.
  1485. @item viper-ESC-moves-cursor-back t
  1486. It @code{t}, cursor moves back 1 character when switching from insert state to vi
  1487. state. If @code{nil}, the cursor stays where it was before the switch.
  1488. @item viper-always t
  1489. @code{t} means: leave it to Viper to decide when a buffer must be brought
  1490. up in Vi state,
  1491. Insert state, or Emacs state. This heuristics works well in virtually all
  1492. cases. @code{nil} means you either has to invoke @code{viper-mode} manually
  1493. for each buffer (or you can add @code{viper-mode} to the appropriate major mode
  1494. hooks using @code{viper-load-hook}).
  1495. This option must be set in your Viper customization file.
  1496. @item viper-custom-file-name "~/.emacs.d/viper"
  1497. File used for Viper-specific customization.
  1498. Change this setting, if you want. Must be set in @file{.emacs}
  1499. before Viper is loaded. Note that you
  1500. have to set it as a string inside double quotes.
  1501. @item viper-spell-function 'ispell-region
  1502. Function used by the command @kbd{#c<move>} to spell.
  1503. @item viper-glob-function
  1504. The value of this variable is the function symbol used to expand wildcard
  1505. symbols. This is platform-dependent. The default tries to set this variable
  1506. to work with most shells, MS Windows, OS/2, etc. However, if it
  1507. doesn't work the way you expect, you should write your own.
  1508. Use @code{viper-glob-unix-files} and @code{viper-glob-mswindows-files} in
  1509. @file{viper-util.el} as examples.
  1510. This feature is used to expand wildcards in the Ex command @kbd{:e}.
  1511. Note that Viper doesn't support wildcards in the @kbd{:r} and @kbd{:w}
  1512. commands, because file completion is a better mechanism.
  1513. @findex @code{viper-glob-function}
  1514. @item ex-cycle-other-window t
  1515. If not @code{nil}, @kbd{:n} and @kbd{:b} will cycle through files in another
  1516. window, if one exists.
  1517. @item ex-cycle-through-non-files nil
  1518. @kbd{:n} does not normally cycle through buffers. Set this to get
  1519. buffers also.
  1520. @item viper-want-emacs-keys-in-insert
  1521. This is set to @code{nil} for user levels 1 and 2 and to @code{t} for user
  1522. levels 3 and 4. Users who specify level 5 are allowed to set this variable
  1523. as they please (the default for this level is @code{t}). If set to
  1524. @code{nil}, complete Vi compatibility is provided in Insert state. This is
  1525. really not recommended, as this precludes you from using language-specific
  1526. features provided by the major modes.
  1527. @item viper-want-emacs-keys-in-vi
  1528. This is set to @code{nil} for user
  1529. level 1 and to @code{t} for user levels 2--4.
  1530. At level 5, users are allowed to set this variable as they please (the
  1531. default for this level is @code{t}).
  1532. If set to @code{nil}, complete Vi compatibility is provided
  1533. in Vi command state. Setting this to @code{nil} is really a bad idea,
  1534. unless you are a novice, as this precludes the use
  1535. of language-specific features provided by the major modes.
  1536. @item viper-keep-point-on-repeat t
  1537. If not @code{nil}, point is not moved when the user repeats the previous
  1538. command by typing a period. This is very useful for doing repeated
  1539. changes with the @kbd{.} key.
  1540. @item viper-repeat-from-history-key 'f12
  1541. Prefix key used to invoke the macros @kbd{f12 1} and @kbd{f12 2} that repeat
  1542. the second-last and the third-last destructive command.
  1543. Both these macros are bound (as Viper macros) to
  1544. @code{viper-repeat-from-history},
  1545. which checks the second key by which it is invoked to see which of the
  1546. previous commands to invoke. Viper binds @kbd{f12 1} and @kbd{f12 2} only,
  1547. but the user can bind more in his/her Viper customization file.
  1548. @xref{Vi Macros}, for how to do this.
  1549. @item viper-keep-point-on-undo nil
  1550. If not @code{nil}, Viper tries to not move point when undoing commands.
  1551. Instead, it will briefly move the cursor to the place where change has
  1552. taken place. However, if the undone piece of text is not seen in window,
  1553. then point will be moved to the place where the change took place.
  1554. Set it to @code{t} and see if you like it better.
  1555. @item viper-delete-backwards-in-replace nil
  1556. If not @code{nil}, @key{DEL} key will delete characters while moving the cursor
  1557. backwards. If @code{nil}, the cursor will move backwards without deleting
  1558. anything.
  1559. @item viper-replace-overlay-face 'viper-replace-overlay-face
  1560. On a graphical display, Viper highlights replacement regions instead of
  1561. putting a @samp{$} at the end. This variable controls the so called
  1562. @dfn{face} used to highlight the region.
  1563. By default, @code{viper-replace-overlay-face} underlines the replacement on
  1564. monochrome displays and also lays a stipple over them. On color displays,
  1565. replacement regions are highlighted with color.
  1566. If you know something about Emacs faces and don't like how Viper highlights
  1567. replacement regions, you can change @code{viper-replace-overlay-face} by
  1568. specifying a new face. (Emacs faces are described in the Emacs Lisp
  1569. reference.) On a color display, the following customization method is
  1570. usually most effective:
  1571. @smallexample
  1572. (set-face-foreground viper-replace-overlay-face "DarkSlateBlue")
  1573. (set-face-background viper-replace-overlay-face "yellow")
  1574. @end smallexample
  1575. For a complete list of colors available to you, evaluate the expression
  1576. @code{(x-defined-colors)}. (Type it in the buffer @file{*scratch*} and then
  1577. hit the @kbd{C-j} key.
  1578. @item viper-replace-overlay-cursor-color "Red"
  1579. @vindex @code{viper-replace-overlay-cursor-color}
  1580. Cursor color when it is inside the replacement region.
  1581. This has effect only on color displays and only when Emacs runs as an X
  1582. application.
  1583. @item viper-insert-state-cursor-color nil
  1584. @vindex @code{viper-insert-state-cursor-color}
  1585. If set to a valid color, this will be the cursor color when Viper is in
  1586. insert state.
  1587. @item viper-emacs-state-cursor-color nil
  1588. @vindex @code{viper-emacs-state-cursor-color}
  1589. If set to a valid color, this will be the cursor color when Viper is in
  1590. emacs state.
  1591. @item viper-replace-region-end-delimiter "$"
  1592. A string used to mark the end of replacement regions. It is used only on
  1593. TTYs or if @code{viper-use-replace-region-delimiters} is non-@code{nil}.
  1594. @item viper-replace-region-start-delimiter ""
  1595. A string used to mark the beginning of replacement regions. It is used
  1596. only on TTYs or if @code{viper-use-replace-region-delimiters} is non-@code{nil}.
  1597. @item viper-use-replace-region-delimiters
  1598. If non-@code{nil}, Viper will always use @code{viper-replace-region-end-delimiter} and
  1599. @code{viper-replace-region-start-delimiter} to delimit replacement regions,
  1600. even on color displays (where this is unnecessary). By default, this
  1601. variable is non-@code{nil} only on TTYs or monochrome displays.
  1602. @item viper-allow-multiline-replace-regions t
  1603. If non-@code{nil}, multi-line text replacement regions, such as those produced by
  1604. commands @kbd{c55w}, @kbd{3C}, etc., will stay around until the user exits
  1605. the replacement mode. In this variable is set to @code{nil}, Viper will
  1606. emulate the standard Vi behavior, which supports only intra-line
  1607. replacement regions (and multi-line replacement regions are deleted).
  1608. @item viper-toggle-key "\C-z"
  1609. Specifies the key used to switch from Emacs to Vi and back.
  1610. Must be set in your Viper customization file. This variable can't be
  1611. changed interactively after Viper is loaded.
  1612. In Insert state, this key acts as a temporary escape to Vi state, i.e., it
  1613. will set Viper up so that the very next command will be executed as if it
  1614. were typed in Vi state.
  1615. @item viper-buffer-search-char nil
  1616. Key used for buffer search. @xref{Viper Specials}, for details.
  1617. @item viper-surrounding-word-function 'viper-surrounding-word
  1618. The value of this variable is a function name that is used to determine
  1619. what constitutes a word clicked upon by the mouse. This is used by mouse
  1620. search and insert.
  1621. @item viper-search-face 'viper-search-face
  1622. Variable that controls how search patterns are highlighted when they are
  1623. found.
  1624. @item viper-vi-state-hook nil
  1625. List of parameterless functions to be run just after entering the Vi
  1626. command state.
  1627. @item viper-insert-state-hook nil
  1628. Same for Insert state. This hook is also run after entering Replace state.
  1629. @item viper-replace-state-hook nil
  1630. List of (parameterless) functions called just after entering Replace state
  1631. (and after all @code{viper-insert-state-hook}).
  1632. @item viper-emacs-state-hook nil
  1633. List of (parameterless) functions called just after switching from Vi state
  1634. to Emacs state.
  1635. @item viper-load-hook nil
  1636. List of (parameterless) functions called just after loading Viper. This is
  1637. the last chance to do customization before Viper is up and running.
  1638. @end table
  1639. @noindent
  1640. You can reset some of these constants in Viper with the Ex command @kbd{:set}
  1641. (when so indicated in the table). Or you
  1642. can include a line like this in your Viper customization file:
  1643. @example
  1644. (setq viper-case-fold-search t)
  1645. @end example
  1646. @vindex @code{viper-auto-indent}
  1647. @vindex @code{viper-electric-mode}
  1648. @vindex @code{viper-case-fold-search}
  1649. @vindex @code{viper-re-search}
  1650. @vindex @code{viper-shift-width}
  1651. @vindex @code{buffer-read-only}
  1652. @vindex @code{viper-search-wrap-around}
  1653. @vindex @code{viper-search-scroll-threshold}
  1654. @vindex @code{viper-search-face}
  1655. @vindex @code{viper-tags-file-name}
  1656. @vindex @code{viper-re-query-replace}
  1657. @vindex @code{viper-want-ctl-h-help}
  1658. @vindex @code{viper-vi-style-in-minibuffer}
  1659. @vindex @code{viper-no-multiple-ESC}
  1660. @vindex @code{viper-always}
  1661. @vindex @code{viper-fast-keyseq-timeout}
  1662. @vindex @code{viper-ex-style-motion}
  1663. @vindex @code{viper-ex-style-editing}
  1664. @vindex @code{viper-ESC-moves-cursor-back}
  1665. @vindex @code{viper-custom-file-name}
  1666. @vindex @code{viper-spell-function}
  1667. @vindex @code{ex-cycle-other-window}
  1668. @vindex @code{ex-cycle-through-non-files}
  1669. @vindex @code{viper-want-emacs-keys-in-insert}
  1670. @vindex @code{viper-want-emacs-keys-in-vi}
  1671. @vindex @code{viper-keep-point-on-repeat}
  1672. @vindex @code{viper-keep-point-on-undo}
  1673. @vindex @code{viper-delete-backwards-in-replace}
  1674. @vindex @code{viper-replace-overlay-face}
  1675. @vindex @code{viper-replace-region-end-symbol}
  1676. @vindex @code{viper-replace-region-start-symbol}
  1677. @vindex @code{viper-allow-multiline-replace-regions}
  1678. @vindex @code{viper-toggle-key}
  1679. @vindex @code{viper-buffer-search-char}
  1680. @vindex @code{viper-surrounding-word-function}
  1681. @vindex @code{viper-vi-state-hook}
  1682. @vindex @code{viper-insert-state-hook}
  1683. @vindex @code{viper-replace-state-hook}
  1684. @vindex @code{viper-emacs-state-hook}
  1685. @node Key Bindings
  1686. @section Key Bindings
  1687. @cindex key bindings
  1688. @cindex keymaps
  1689. Viper lets you define hot keys, i.e., you can associate keyboard keys
  1690. such as F1, Help, PgDn, etc., with Emacs Lisp functions (that may already
  1691. exist or that you will write). Each key has a ``preferred form'' in
  1692. Emacs. For instance, the Up key's preferred form is [up], the Help key's
  1693. preferred form is [help], and the Undo key has the preferred form [f14].
  1694. You can find out the preferred form of a key by typing @kbd{M-x
  1695. describe-key-briefly} and then typing the key you want to know about.
  1696. Under the X Window System, every keyboard key emits its preferred form,
  1697. so you can just type
  1698. @lisp
  1699. (global-set-key [f11] 'calendar) ; L1, Stop
  1700. (global-set-key [f14] 'undo) ; L4, Undo
  1701. @end lisp
  1702. @noindent
  1703. to bind L1 (a key that exists on some SUN workstations) so it will invoke
  1704. the Emacs Calendar and to bind L4 so it will undo changes.
  1705. However, on a dumb terminal or in an Xterm window, even the standard arrow
  1706. keys may
  1707. not emit the right signals for Emacs to understand. To let Emacs know about
  1708. those keys, you will have to find out which key sequences they emit
  1709. by typing @kbd{C-q} and then the key (you should switch to Emacs state
  1710. first). Then you can bind those sequences to their preferred forms using
  1711. @code{input-decode-map} as follows:
  1712. @lisp
  1713. (cond ((string= (getenv "TERM") "xterm")
  1714. (define-key input-decode-map "\e[192z" [f11]) ; L1
  1715. (define-key input-decode-map "\e[195z" [f14]) ; L4, Undo
  1716. @end lisp
  1717. The above illustrates how to do this for Xterm. On VT100, you would have to
  1718. replace "xterm" with "vt100" and also change the key sequences (the same
  1719. key may emit different sequences on different types of terminals).
  1720. The above keys are global, so they are overwritten by the local maps
  1721. defined by the major modes and by Viper itself. Therefore, if you wish to
  1722. change a binding set by a major mode or by Viper, read this.
  1723. Viper users who wish to specify their own key bindings should be concerned
  1724. only with the following three keymaps:
  1725. @code{viper-vi-global-user-map} for Vi state commands,
  1726. @code{viper-insert-global-user-map} for Insert state commands,
  1727. and @code{viper-emacs-global-user-map} for Emacs state commands (note:
  1728. customized bindings for Emacs state made to @code{viper-emacs-global-user-map}
  1729. are @emph{not} inherited by Insert state).
  1730. For more information on Viper keymaps, see the header of the file
  1731. @file{viper.el}.
  1732. If you wish to change a Viper binding, you can use the
  1733. @code{define-key} command, to modify @code{viper-vi-global-user-map},
  1734. @code{viper-insert-global-user-map}, and @code{viper-emacs-global-user-map}, as
  1735. explained below. Each of these key maps affects the corresponding Viper state.
  1736. The keymap @code{viper-insert-global-user-map} also affects Viper's Replace
  1737. state.
  1738. @noindent
  1739. If you want to
  1740. bind a key, say @kbd{C-v}, to the function that scrolls
  1741. page down and to make @kbd{0} display information on the current buffer,
  1742. putting this in your Viper customization file will do the trick in Vi state:
  1743. @example
  1744. (define-key viper-vi-global-user-map "\C-v" 'scroll-down)
  1745. @end example
  1746. @noindent
  1747. To set a key globally,
  1748. @example
  1749. (define-key viper-emacs-global-user-map "\C-c m" 'smail)
  1750. (define-key viper-vi-global-user-map "0" 'viper-info-on-file)
  1751. @end example
  1752. @noindent
  1753. Note, however, that this binding may be overwritten by other keymaps, since
  1754. the global keymap has the lowest priority.
  1755. To make sure that nothing will override a binding in Emacs state, you
  1756. can write this:
  1757. @example
  1758. (define-key viper-emacs-global-user-map "\C-c m" 'smail)
  1759. @end example
  1760. @noindent
  1761. To customize the binding for @kbd{C-h} in Insert state:
  1762. @example
  1763. (define-key viper-insert-global-user-map "\C-h"
  1764. 'my-del-backwards-function)
  1765. @end example
  1766. @noindent
  1767. Each Emacs command key calls some Lisp function. If you have enabled the
  1768. Help, (@pxref{Rudimentary Changes}) @kbd{C-h k} will show you the function
  1769. for each specific key; @kbd{C-h b} will show all bindings, and @kbd{C-h m}
  1770. will provide information on the major mode in effect. If Help is not
  1771. enabled, you can still get help in Vi state by prefixing the above commands
  1772. with @kbd{\}, e.g., @kbd{\ C-h k} (or you can use the Help menu in the
  1773. menu bar, if Emacs runs under X).
  1774. Viper users can also change bindings on a per major mode basis. As with
  1775. global bindings, this can be done separately for each of the three main Viper
  1776. states. To this end, Viper provides the function
  1777. @code{viper-modify-major-mode}.
  1778. @findex @code{viper-modify-major-mode}
  1779. To modify keys in Emacs state for @code{my-favorite-major-mode}, the user
  1780. needs to create a sparse keymap, say, @code{my-fancy-map}, bind whatever
  1781. keys necessary in that keymap, and put
  1782. @example
  1783. (viper-modify-major-mode 'dired-mode 'emacs-state my-fancy-map)
  1784. @end example
  1785. @noindent
  1786. in your Viper customization file. To do the same in Vi and Insert states, you
  1787. should use @code{vi-state} and @code{insert-state}. Changes in Insert state
  1788. are also in effect in Replace state. For instance, suppose that the user wants
  1789. to use @kbd{dd} in Vi state under Dired mode to delete files, @kbd{u} to unmark
  1790. files, etc. The following code in the Viper customization file will then do
  1791. the job:
  1792. @example
  1793. (setq my-dired-modifier-map (make-sparse-keymap))
  1794. (define-key my-dired-modifier-map "dd" 'dired-flag-file-deletion)
  1795. (define-key my-dired-modifier-map "u" 'dired-unmark)
  1796. (viper-modify-major-mode 'dired-mode 'vi-state my-dired-modifier-map)
  1797. @end example
  1798. A Vi purist may want to modify Emacs state under Dired mode so that
  1799. @kbd{k}, @kbd{l}, etc., will move around in directory buffers, as in
  1800. Vi. Although this is not recommended, as these keys are bound to useful
  1801. Dired functions, the trick can be accomplished via the following code:
  1802. @example
  1803. (setq my-dired-vi-purist-map (make-sparse-keymap))
  1804. (define-key my-dired-vi-purist-map "k" 'viper-previous-line)
  1805. (define-key my-dired-vi-purist-map "l" 'viper-forward-char)
  1806. (viper-modify-major-mode 'dired-mode
  1807. 'emacs-state my-dired-vi-purist-map)
  1808. @end example
  1809. Yet another way to customize key bindings in a major mode is to edit the
  1810. list @code{viper-major-mode-modifier-list} using the customization widget.
  1811. @vindex @code{viper-major-mode-modifier-list}
  1812. (This variable is in the Viper-misc customization group.)
  1813. The elements of this list are triples of the form: (major-mode viper-state
  1814. keymap), where the keymap contains bindings that are supposed to be active
  1815. in the given major mode and the given viper-state.
  1816. Effects similar to key binding changes can be achieved by defining Vi
  1817. keyboard macros using the Ex commands @kbd{:map} and @kbd{:map!}. The
  1818. difference is that multi-key Vi macros do not override the keys they are
  1819. bound to, unless these keys are typed in quick succession. So, with macros,
  1820. one can use the normal keys alongside with the macros. If per-mode
  1821. modifications are needed, the user can try both ways and see which one is
  1822. more convenient.
  1823. @findex @kbd{Ex map}
  1824. @xref{Vi Macros}, for details.
  1825. Note: in major modes that come up in @emph{Emacs state} by default, the
  1826. aforesaid modifications may not take place immediately (but only after the
  1827. buffer switches to some other Viper state and then back to Emacs state). To
  1828. avoid this, one should add @code{viper-change-state-to-emacs} to an
  1829. appropriate hook of that major mode. (Check the function
  1830. @code{viper-set-hooks} in @file{viper.el} for examples.) However, if you
  1831. did not set @code{viper-always} to @code{nil}, chances are that you won't
  1832. need to perform the above procedure, because Viper will take care of most
  1833. useful defaults.
  1834. Finally, Viper has a facility that lets the user define per-buffer
  1835. bindings, i.e., bindings that are in effect in some specific buffers
  1836. only. Unlike per-mode bindings described above, per-buffer bindings can be
  1837. defined based on considerations other than the major mode. This is done
  1838. via the function @code{viper-add-local-keys}, which lets one specify bindings
  1839. that should be in effect in the current buffer only and for a specific Viper
  1840. state. For instance,
  1841. @lisp
  1842. (viper-add-local-keys 'vi-state '(("ZZ" .@: TeX-command-master)
  1843. ("ZQ" .@: viper-save-kill-buffer)))
  1844. @end lisp
  1845. @noindent
  1846. redefines @kbd{ZZ} to invoke @code{TeX-command-master} in @code{vi-state}
  1847. and @kbd{ZQ} to save-then-kill the current buffer. These bindings take
  1848. effect only in the buffer where this command is executed. The typical use
  1849. of this function is to execute the above expression from within a function
  1850. that is included in a hook to some major mode. For instance, the above
  1851. expression
  1852. could be called from a function, @code{my-tex-init}, which may be added to
  1853. @code{tex-mode-hook} as follows:
  1854. @lisp
  1855. (add-hook 'tex-mode-hook 'my-tex-init)
  1856. @end lisp
  1857. @noindent
  1858. When TeX mode starts, the hook is executed and the above Lisp expression is
  1859. evaluated. Then, the bindings for @kbd{ZZ} and @kbd{ZQ} are changed in Vi
  1860. command mode for all buffers in TeX mode.
  1861. Another useful application is to bind @kbd{ZZ} to @code{send-mail}
  1862. in the Mail mode buffers (the specifics of this depend on which mail
  1863. package you are using, @code{rmail}, @code{mh-e}, @code{vm}, etc.
  1864. For instance, here is how to do this for @code{mh-e}, the Emacs interface
  1865. to MH:
  1866. @lisp
  1867. (defun mh-add-vi-keys ()
  1868. "Set up ZZ for MH-e and XMH."
  1869. (viper-add-local-keys 'vi-state '(("ZZ" .@: mh-send-letter))))
  1870. (add-hook 'mh-letter-mode-hook 'mh-add-vi-keys)
  1871. @end lisp
  1872. You can also use @code{viper-add-local-keys} to set per buffer
  1873. bindings in Insert state and Emacs state by passing as a parameter the
  1874. symbols @code{insert-state} and @code{emacs-state}, respectively.
  1875. As with global bindings, customized local bindings done to Emacs state
  1876. are not inherited by Insert state.
  1877. On rare occasions, local keys may be added by mistake. Usually this is done
  1878. indirectly, by invoking a major mode that adds local keys (e.g.,
  1879. @code{shell-mode} redefines @key{RET}). In such a case, exiting the wrong
  1880. major mode won't rid you from unwanted local keys, since these keys are
  1881. local to Viper state and the current buffer, not to the major mode.
  1882. In such situations, the remedy is to type @kbd{M-x viper-zap-local-keys}.
  1883. So much about Viper-specific bindings.
  1884. @xref{Customization,,Customization,emacs,The GNU Emacs
  1885. Manual}, and the Emacs quick reference card for the general info on key
  1886. bindings in Emacs.
  1887. @vindex @code{input-decode-map}
  1888. @vindex @code{function-key-map}
  1889. @vindex @code{viper-vi-global-user-map}
  1890. @vindex @code{viper-insert-global-user-map}
  1891. @vindex @code{viper-emacs-global-user-map}
  1892. @findex @code{viper-add-local-keys}
  1893. @findex @code{viper-zap-local-keys}
  1894. @node Packages that Change Keymaps
  1895. @section Packages that Change Keymaps
  1896. @cindex C-c and Viper
  1897. @cindex Viper and C-c
  1898. Viper is designed to coexist with all major and minor modes of Emacs. This
  1899. means that bindings set by those modes are generally available with Viper
  1900. (unless you explicitly prohibit them by setting
  1901. @code{viper-want-emacs-keys-in-vi} and @code{viper-want-emacs-keys-in-insert} to
  1902. @code{nil}).
  1903. If @code{viper-always} is set to @code{t} (which is the default), Viper
  1904. will try to bring each buffer
  1905. in the Viper state that is most appropriate for that buffer.
  1906. Usually, this would be the Vi state, but sometimes it could be the Insert
  1907. state or the Emacs state.
  1908. Some major mode bindings will necessarily be overwritten by Viper. Indeed, in
  1909. Vi state, most of the 1-character keys are used for Vi-style editing. This
  1910. usually causes no problems because most packages designed for editing files
  1911. typically do not bind such keys. Instead, they use key sequences that start
  1912. with @kbd{C-x} and @kbd{C-c}. This is why it was so important for us to
  1913. free up @kbd{C-x} and @kbd{C-c}.
  1914. It is common for language-specific major modes to bind @key{TAB} and
  1915. @kbd{C-j} (the line feed) keys to various formatting functions. This is
  1916. extremely useful, but may require some getting used to for a Vi user. If you
  1917. decide that this feature is not for you, you can re-bind these keys as
  1918. explained earlier (@pxref{Customization}).
  1919. Binding for @key{TAB} is one of the most unusual aspects of Viper for many
  1920. novice users. In Emacs, @key{TAB} is used to format text and programs, and
  1921. is extremely useful. For instance, hitting @key{TAB} causes the current
  1922. line to be re-indented in accordance with the context. In programming,
  1923. this is very important, since improper automatic indentation would
  1924. immediately alert the programmer to a possible error. For instance, if a
  1925. @kbd{)} or a @kbd{"} is missing somewhere above the current
  1926. line, @key{TAB} is likely to mis-indent the line.
  1927. For this reason, Viper doesn't change the standard Emacs binding of
  1928. @key{TAB}, thereby sacrificing Vi compatibility
  1929. (except for users at level 1). Instead, in Viper, the key
  1930. @kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @key{TAB}.
  1931. We should note that on some non-windowing terminals, Shift doesn't modify
  1932. the @key{TAB} key, so @kbd{S-tab} behaves as if it were @key{TAB}. In such
  1933. a case, you will have to bind @code{viper-insert-tab} to some other
  1934. convenient key.
  1935. Some packages, notably Dired, Gnus, Info, etc., attach special meaning to
  1936. common keys like @key{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others. This
  1937. means that Vi command state is inappropriate for working with these
  1938. packages. Fortunately, these modes operate on read-only buffers and are
  1939. designed not for editing files, but for special-purpose browsing, reading
  1940. news, mail, etc., and Vi commands are meaningless in these situations. For
  1941. this reason, Viper doesn't force Vi state on such major modes---it
  1942. brings them in Emacs state. You can switch to Vi state by typing @kbd{C-z}
  1943. if, for instance, you want to do Vi-style search in a buffer (although,
  1944. usually, incremental search, which is bound to @kbd{C-s}, is sufficient in
  1945. these situations). But you should then switch back to Emacs state if you
  1946. plan to continue using these major modes productively. You can also switch
  1947. to Vi temporarily, to execute just one command. This is done by typing
  1948. @kbd{C-c \}. (In some of these modes, @kbd{/} and @kbd{:} are bound
  1949. Vi-style, unless these keys perform essential duties.)
  1950. If you would like certain major modes to come up in Emacs state rather than
  1951. Vi state (but Viper thinks otherwise), you should put these major modes
  1952. on the @code{viper-emacs-state-mode-list} list and delete them from
  1953. @code{viper-vi-state-mode-list}.
  1954. Likewise, you can force Viper's Insert state on a major mode by putting it
  1955. in @code{viper-insert-state-mode-list}.
  1956. @vindex @code{viper-emacs-state-mode-list}
  1957. @vindex @code{viper-insert-state-mode-list}
  1958. @vindex @code{viper-vi-state-mode-list}
  1959. It is also possible to impose Vi on some major modes, even though they may
  1960. bind common keys to specialized commands. This might make sense for modes
  1961. that bind only a small number of common keys. For instance, Viper subverts
  1962. the Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} using
  1963. @code{viper-add-local-keys} described in the section on customization
  1964. (@pxref{Customization}).
  1965. In some cases, some @emph{minor} modes might override certain essential
  1966. bindings in Vi command state. This is not a big problem because this
  1967. can happen only in the beginning, when the minor mode kicks in. Typing
  1968. @code{M-x viper-mode} will correct the situation. Viper knows about
  1969. several such minor modes and takes care of them, so the above trick
  1970. is usually not necessary. If you find that some minor mode, e.g.,
  1971. @code{nasty-mode} interferes with Viper, putting the following in
  1972. your Viper customization file should fix the problem:
  1973. @lisp
  1974. (viper-harness-minor-mode "nasty-mode")
  1975. @end lisp
  1976. @noindent
  1977. The argument to @code{viper-harness-minor-mode} is the name of the file for the
  1978. offending minor mode with the suffixes @file{.el} and @file{.elc} removed.
  1979. It may not be always obvious which minor mode is at fault. The only
  1980. guidance here is to look into the file that defines the minor mode you are
  1981. suspecting, say @file{nasty-mode.el}, and see if it has a variable called
  1982. @code{nasty-mode-map}. Then check if there is a statement of the form
  1983. @lisp
  1984. (define-key nasty-mode-map key function)
  1985. @end lisp
  1986. @noindent
  1987. that binds the misbehaving
  1988. keys. If so, use the above line to harness @code{nasty-mode}. If your
  1989. suspicion is wrong, no harm is done if you harness a minor mode that
  1990. doesn't need to be harnessed.
  1991. It is recommended to harness even those minor modes that don't override
  1992. Viper keys, but still have their own keymaps. A general way to
  1993. make a minor mode, @code{my-mode},
  1994. compatible with Viper is to have the file @file{my-mode.el} include the following code:
  1995. @lisp
  1996. (when (fboundp 'viper-harness-minor-mode)
  1997. (let ((lib (file-name-sans-extension
  1998. (file-name-nondirectory load-file-name))))
  1999. (viper-harness-minor-mode lib)))
  2000. @end lisp
  2001. @vindex @code{viper-want-emacs-keys-in-vi}
  2002. @vindex @code{viper-want-emacs-keys-in-insert}
  2003. @vindex @code{viper-always}
  2004. @findex @code{viper-set-hooks}
  2005. @findex @code{viper-mode}
  2006. @findex @code{viper-harness-minor-mode}
  2007. @findex @code{remove-hook}
  2008. @findex @code{add-hook}
  2009. @node Viper Specials
  2010. @section Viper Specials
  2011. Viper extends Vi with a number of useful features. This includes various
  2012. search functions, histories of search strings, Ex commands, insertions, and
  2013. Vi's destructive commands. In addition, Viper supports file name completion
  2014. and history, completion of Ex commands and variables, and many other
  2015. features. Some of these features are explained in detail elsewhere in this
  2016. document. Other features are explained here.
  2017. @table @code
  2018. @item (viper-buffer-search-enable)
  2019. @item viper-buffer-search-char nil
  2020. Enable buffer search. Explicit call to @code{viper-buffer-search-enable}
  2021. sets @code{viper-buffer-search-char} to @kbd{g}. Alternatively, the user can
  2022. set @code{viper-buffer-search-char} in his/her Viper customization file to a key
  2023. sequence to be used for buffer search. There is no need to call
  2024. @code{viper-buffer-search-enable} in that case.
  2025. @findex @code{viper-buffer-search-enable}
  2026. @vindex @code{viper-buffer-search-char}
  2027. @item viper-toggle-search-style
  2028. This function, bound to @kbd{C-c /}, lets one toggle case-sensitive and
  2029. case-insensitive search, and also switch between plain vanilla search and
  2030. search via regular expressions. Without the prefix argument, the user is
  2031. asked which mode to toggle. With prefix argument 1, this toggles
  2032. case-sensitivity. With prefix argument 2, regular expression/vanilla search
  2033. will be toggled.
  2034. However, we found that the most convenient way to toggle
  2035. these options is to bind a Vi macro to
  2036. bind @kbd{//} to toggles case sensitivity and to @kbd{///} to toggles
  2037. vanilla search. Thus, quickly hitting @kbd{/} twice will switch Viper from
  2038. case sensitive search to case-insensitive. Repeating this once again will
  2039. restore the original state. Likewise, quickly hitting @kbd{/} three times
  2040. will switch you from vanilla-style search to search via regular expressions.
  2041. If you hit something other than @kbd{/} after the first @kbd{/} or if the
  2042. second @kbd{/} doesn't follow quickly enough, then Viper will issue the
  2043. usual prompt @kbd{/} and will wait for input, as usual in Vi.
  2044. If you don't like this behavior, you can ``unrecord'' these macros in your
  2045. Viper customization file. For instance, if you don't like the above
  2046. feature, put this in the file:
  2047. @example
  2048. (viper-set-searchstyle-toggling-macros 'undefine)
  2049. @end example
  2050. @findex @code{viper-set-searchstyle-toggling-macros}
  2051. If you don't like this feature as a default, but would still like to have
  2052. it in some major modes, you can do so by first unsetting it globally, as
  2053. shown above, and then setting it in the desired major modes as follows:
  2054. @example
  2055. (viper-set-searchstyle-toggling-macros nil 'c-mode)
  2056. (viper-set-searchstyle-toggling-macros nil 'lisp-mode)
  2057. @end example
  2058. @item Vi-isms in Emacs state
  2059. Some people find it useful to use the Vi-style search key, @kbd{/}, to invoke
  2060. search in modes which Viper leaves in emacs-state. These modes are:
  2061. @code{dired-mode}, @code{mh-folder-mode},
  2062. @code{Info-mode}, and @code{Buffer-menu-mode}
  2063. (more may be added in the future). So, in the above modes, Viper binds @kbd{/}
  2064. so that it will behave Vi-style. Furthermore, in those major modes, Viper
  2065. binds @kbd{:} to invoke ex-style commands, like in vi-state. And, as described
  2066. above, @kbd{//} and @kbd{///} get bound to Vi-style macros that toggle
  2067. case-insensitivity and regexp-search.
  2068. If you don't like these features---which I don't really understand---you
  2069. can unbind @kbd{/} and @kbd{:} in @code{viper-dired-modifier-map} (for
  2070. Dired) or in @code{viper-slash-and-colon-map}, for other modes.
  2071. @vindex @code{viper-slash-and-colon-map}
  2072. @vindex @code{viper-dired-modifier-map}
  2073. To unbind the macros @kbd{//} and @kbd{///} for a major mode where you
  2074. feel they
  2075. are undesirable, execute @code{viper-set-emacs-state-searchstyle-macros} with a
  2076. non-@code{nil} argument. This can be done either interactively, by supplying a
  2077. prefix argument, or by placing
  2078. @example
  2079. (viper-set-emacs-state-searchstyle-macros 'undefine)
  2080. @end example
  2081. @findex @code{viper-set-emacs-state-searchstyle-macros}
  2082. in the hook to the major mode (e.g., @code{dired-mode-hook}).
  2083. @xref{Vi Macros}, for more information on Vi macros.
  2084. @item viper-heading-start
  2085. @item viper-heading-end
  2086. @cindex headings
  2087. @cindex sections
  2088. @cindex paragraphs
  2089. @cindex sentences
  2090. Regular Expressions for @kbd{[[} and @kbd{]]}. Note that Emacs defines
  2091. Regexps for paragraphs and sentences. @xref{Paragraphs,,Paragraphs and
  2092. Sentences,emacs,The GNU Emacs Manual}, for details.
  2093. @item M-x viper-set-expert-level
  2094. @findex @code{viper-set-expert-level}
  2095. Change your user level interactively.
  2096. @item viper-smart-suffix-list '("" "tex" "c" "cc" "el" "p")
  2097. @vindex @code{viper-smart-suffix-list}
  2098. Viper supports Emacs-style file completion when it prompts the user for a
  2099. file name. However, in many cases, the same directory may contain files
  2100. with identical prefix but different suffixes, e.g., prog.c, prog.o,
  2101. paper.tex, paper.dvi. In such cases, completion will stop at the period.
  2102. If the above variable is a list of strings representing suffixes, Viper will
  2103. try these suffixes
  2104. in the order listed and will check if the corresponding file exists.
  2105. For instance, if completion stopped at @samp{paper.} and the user
  2106. typed @key{RET}, then Viper will check if the files @file{paper.},
  2107. @file{paper.tex}, @file{paper.c}, etc., exist.
  2108. It will take the first such file. If no file exists, Viper will give a chance
  2109. to complete the file name by typing the appropriate suffix.
  2110. If @file{paper.} was
  2111. the intended file name, hitting return will accept it.
  2112. To turn this feature off, set the above variable to @code{nil}.
  2113. @item viper-insertion-ring-size 14
  2114. @vindex @code{viper-insertion-ring-size}
  2115. @cindex Insertion ring
  2116. Viper remembers what was previously inserted in Insert and Replace states.
  2117. Several such recent insertions are kept in a special ring of strings of size
  2118. @code{viper-insertion-ring-size}.
  2119. If you enter Insert or Replace state you can reinsert strings from this
  2120. ring by typing @kbd{C-c M-p} or @kbd{C-c M-n}. The former will search the
  2121. ring in
  2122. the direction of older insertions, and the latter will search in
  2123. the direction of newer insertions. Hitting @kbd{C-c M-p} or @kbd{C-c M-n}
  2124. in succession
  2125. will undo the previous insertion from the ring and insert the next item on
  2126. the ring. If a larger ring size is needed, change the value of the above
  2127. variable in the Viper customization file.
  2128. Since typing these sequences of keys may be tedious, it is suggested that the
  2129. user should bind a function key, such as @kbd{f31}, as follows:
  2130. @example
  2131. (define-key viper-insert-global-user-map [f31]
  2132. 'viper-insert-prev-from-insertion-ring)
  2133. @end example
  2134. This binds @kbd{f31} (which is usually @kbd{R11} on a Sun workstation)
  2135. to the function that inserts the previous string in the insertion history.
  2136. To rotate the history in the opposite
  2137. direction, you can either bind an unused key to
  2138. @code{viper-insert-next-from-insertion-ring} or hit any digit (1 to 9) then
  2139. @kbd{f31}.
  2140. One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
  2141. this will interfere with the minibuffer histories and, possibly, other
  2142. major modes.
  2143. @item viper-command-ring-size 14
  2144. @vindex @code{viper-command-ring-size}
  2145. @cindex Destructive command ring
  2146. @cindex Destructive command history
  2147. Viper keeps track of the recent history of destructive
  2148. commands, such as @kbd{dw}, @kbd{i}, etc.
  2149. In Vi state,
  2150. the most recent command can be re-executed by hitting a period, as in Vi.
  2151. However, repeated typing @kbd{C-c M-p} will cause Viper to show the
  2152. previous destructive commands in the minibuffer. Subsequent hitting period
  2153. will execute the command that was displayed last.
  2154. The key @kbd{C-c M-n} will cycle through the command history in the
  2155. opposite direction.
  2156. Since typing @kbd{C-c M-p} may be tedious, it is more convenient to bind an
  2157. appropriate function to an unused function key on the keyboard and use that
  2158. key. For instance, the following
  2159. @example
  2160. (define-key viper-vi-global-user-map [f31]
  2161. 'viper-prev-destructive-command)
  2162. @end example
  2163. binds the key @kbd{f31} (which is usually @kbd{R11} on a Sun workstation)
  2164. to the function that searches the command history in the direction of older
  2165. commands. To search in the opposite
  2166. direction, you can either bind an unused key to
  2167. @code{viper-next-destructive-command} or hit any digit (1 to 9) then @kbd{f31}.
  2168. One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
  2169. this will interfere with the minibuffer histories and, possibly, other
  2170. major modes.
  2171. @item viper-minibuffer-vi-face 'viper-minibuffer-vi-face
  2172. @item viper-minibuffer-insert-face 'viper-minibuffer-insert-face
  2173. @item viper-minibuffer-emacs-face 'viper-minibuffer-emacs-face
  2174. These faces control the appearance of the minibuffer text in the
  2175. corresponding Viper states. You can change the appearance of these faces
  2176. through Emacs's customization widget, which is accessible through the
  2177. menubar.
  2178. Viper is located in this widget under the @emph{Emulations} customization
  2179. subgroup of the @emph{Editing} group. All Viper faces are grouped together
  2180. in Viper's @emph{Highlighting} customization subgroup.
  2181. Note that only the text you type in is affected by the above faces.
  2182. Prompts and minibuffer messages are not affected.
  2183. Purists who do not like adornments in the minibuffer can always zap them by
  2184. putting
  2185. @example
  2186. (copy-face 'default 'viper-minibuffer-vi-face)
  2187. (copy-face 'default 'viper-minibuffer-insert-face)
  2188. (copy-face 'default 'viper-minibuffer-emacs-face)
  2189. @end example
  2190. in their Viper customization file or through the customization widget, as
  2191. described above. However, in that case, the user will not have any
  2192. indication of the current Viper state in the minibuffer. (This is important
  2193. if the user accidentally switches to another Viper state by typing @key{ESC} or
  2194. @kbd{C-z}).
  2195. @item M-x viper-go-away
  2196. @findex @code{viper-go-away}
  2197. Make Viper disappear from the face of your running Emacs instance. If your
  2198. fingers start aching again, @kbd{M-x viper-mode} might save your day.
  2199. @item M-x toggle-viper-mode
  2200. @findex @code{toggle-viper-mode}
  2201. Toggle Viperization of Emacs on and off.
  2202. @end table
  2203. @cindex Multifile documents and programs
  2204. Viper provides some support for multi-file documents and programs.
  2205. If a document consists of several files we can designate one of them as a
  2206. master and put the following at the end of that file:
  2207. @lisp
  2208. ;; Local Variables:
  2209. ;; eval: (viper-setup-master-buffer "file1" "file2" "file3" "file4")
  2210. ;; End:
  2211. @end lisp
  2212. @noindent
  2213. where @code{file1} to @code{file4} are names of files related to the master
  2214. file. Next time, when the master file is visited, the command
  2215. @code{viper-setup-master-buffer} will be evaluated and the above files will
  2216. be associated with the master file. Then, the new Ex command
  2217. @kbd{:RelatedFile} (abbr.@: @kbd{:R}) will display files 1 to 4 one after
  2218. another, so you can edit them. If a file is not in any Emacs buffer, it
  2219. will be visited. The command @kbd{PreviousRelatedFile} (abbr., @kbd{:P})
  2220. goes through the file list in the opposite direction.
  2221. @findex @kbd{Ex RelatedFile}
  2222. @findex @kbd{Ex PreviousRelatedFile}
  2223. These commands are akin to @kbd{:n} and @kbd{:N}, but they allow the user to
  2224. focus on relevant files only.
  2225. Note that only the master file needs to have the aforementioned block of
  2226. commands. Also, ";;" above can be replaced by some other
  2227. markers. Semicolon is good for Lisp programs, since it is considered a
  2228. comment designator there. For LaTeX, this could be "%%%", and for C the
  2229. above block should be commented out.
  2230. Even though these commands are sometimes useful, they are no substitute for
  2231. the powerful @emph{tag table} facility of Emacs. Viper's @kbd{:tag} command
  2232. in a primitive interface to Emacs tags. @xref{Tags,Tags,Tags,emacs,
  2233. The GNU Emacs Manual}, for more information on tags.
  2234. The following two commands are normally bound to a mouse click and are part
  2235. of Viper. They work only if Emacs runs as an application under X
  2236. Windows (or under some other window system for which a port of GNU Emacs 20
  2237. is available). Clicking the mouse when Emacs is invoked in an Xterm window
  2238. (using @code{emacs -nw}) will do no good.
  2239. @table @code
  2240. @cindex mouse
  2241. @cindex mouse-search
  2242. @item viper-mouse-search-key (meta shift 1)
  2243. @vindex @code{viper-mouse-insert-key}
  2244. This variable controls the @emph{mouse-search} feature of Viper. The
  2245. default value
  2246. states that holding Meta and Shift keys while clicking mouse button 1
  2247. should initiate search for a region under the mouse pointer (defined
  2248. below). This command can take a prefix argument, which indicates the
  2249. occurrence of the pattern to search for.
  2250. Note: while loading initially, Viper binds this mouse action only if it is
  2251. not already bound to something else. If you want to use the mouse-search
  2252. feature, and the @kbd{Meta-Shift-Mouse-1} mouse action is already bound to
  2253. something else, you can rebind the mouse-search feature by setting
  2254. @code{viper-mouse-search-key} to something else in
  2255. your Viper customization file:
  2256. @lisp
  2257. (setq viper-mouse-search-key '(meta 1))
  2258. @end lisp
  2259. This would bind mouse search to the action invoked by pressing the
  2260. Meta key and clicking mouse button 1. The allowed values of
  2261. @code{viper-mouse-search-key} are lists that contain a mouse-button number
  2262. (1,2, or 3) and any combination of the words ``control'', ``meta'', and
  2263. ``shift''.
  2264. If the requested mouse action (e.g., (meta 1)) is already taken for other
  2265. purposes then you have to confirm your intention by placing the following
  2266. command in your Viper customization file after setting
  2267. @code{viper-mouse-search-key}:
  2268. @lisp
  2269. (viper-bind-mouse-search-key 'force)
  2270. @end lisp
  2271. You can also change this setting interactively, through the customization
  2272. widget of Emacs (type @kbd{:customize}).
  2273. The region that is chosen as a pattern to search for is determined as
  2274. follows. If search is invoked via a single click, Viper chooses the region
  2275. that lies between the beginning of the ``word'' under the pointer (``word''
  2276. is understood in Vi sense) and the end of that word. The only difference
  2277. with Vi's words is that in Lisp major modes @samp{-} is considered an
  2278. alphanumeric symbol. This is done for the convenience of working with Lisp
  2279. symbols, which often have an @samp{-} in them. Also, if you click on a
  2280. non-alphanumeric character that is not a word separator (in Vi sense) then
  2281. this character will also be considered alphanumeric, provided that it is
  2282. adjacent (from either side) to an alphanumeric character. This useful
  2283. feature gives added control over the patterns selected by the mouse click.
  2284. On a double-click, the region is determined by the beginning of the current
  2285. Vi's ``Word'' (i.e., the largest non-separator chunk of text) and the End
  2286. of that ``Word'' (as determined by the @kbd{E} command).
  2287. On a triple-click, the region consists of the entire line where the click
  2288. occurred with all leading and trailing spaces and tabs removed.
  2289. @cindex mouse-insert
  2290. @item viper-mouse-insert-key (meta shift 2)
  2291. @vindex @code{viper-mouse-insert-key}
  2292. This variable controls the @emph{mouse-insert} feature of Viper.
  2293. The above default value states that
  2294. holding Meta and Shift keys while clicking mouse button 2
  2295. should insert the region surrounding the
  2296. mouse pointer. The rules defining this region are the same as for
  2297. mouse-search. This command takes an optional prefix argument, which
  2298. indicates how many such regions to snarf from the buffer and insert. (In
  2299. case of a triple-click, the prefix argument is ignored.)
  2300. Note: while loading initially, Viper binds this mouse action only if it not
  2301. already bound to something else. If you want to use this feature and the
  2302. default mouse action is already bound, you can rebind mouse-insert by
  2303. placing this command in your Viper customization file:
  2304. @lisp
  2305. (setq viper-mouse-insert-key '(meta 2))
  2306. @end lisp
  2307. If you want to bind mouse-insert to an action even if this action is
  2308. already taken for other purposes in Emacs, then you should add this command
  2309. to your Viper customization file, after setting @code{viper-mouse-insert-key}:
  2310. @lisp
  2311. (viper-bind-mouse-insert-key 'force)
  2312. @end lisp
  2313. This value can also be changed via the Emacs customization widget at the
  2314. menubar.
  2315. @item viper-multiclick-timeout
  2316. This variable controls the rate at which double-clicking must occur for the
  2317. purpose of mouse search and mouse insert. By default, this is set to
  2318. @code{double-click-time} in Emacs and to
  2319. @code{mouse-track-multi-click-time} milliseconds in XEmacs.
  2320. @end table
  2321. @kindex @kbd{S-Mouse-1}
  2322. @kindex @kbd{S-Mouse-2}
  2323. @kindex @kbd{meta shift button1up}
  2324. @kindex @kbd{meta shift button2up}
  2325. @vindex @code{viper-multiclick-timeout}
  2326. @findex @code{viper-mouse-click-insert-word}
  2327. @findex @code{viper-mouse-click-search-word}
  2328. Note: The above functions search and insert in the selected window of
  2329. the latest active frame. This means that you can click in another window or
  2330. another frame and have search or insertion done in the frame and window you
  2331. just left. This lets one use these functions in a multi-frame
  2332. configuration. However, this may require some getting used to. For
  2333. instance, if you are typing in a frame, A, and then move the mouse to frame
  2334. B and click to invoke mouse search, search (or insertion) will be performed
  2335. in frame A@. To perform search/insertion in frame B, you will first have to
  2336. shift focus there, which doesn't happen until you type a character or
  2337. perform some other action in frame B---mouse search doesn't shift focus.
  2338. If you decide that you don't like the above feature and always want
  2339. search/insertion be performed in the frame where the click occurs, don't
  2340. bind (and unbind, if necessary) @code{viper-mouse-catch-frame-switch} from
  2341. the mouse event it is bound to.
  2342. Mouse search is integrated with Vi-style search, so you can
  2343. repeat it with @kbd{n} and @kbd{N}. It should be also noted that, while
  2344. case-sensitivity of search in Viper is controlled by the variable
  2345. @code{viper-case-fold-search}, the case of mouse search is
  2346. controlled by the Emacs variable @code{case-fold-search}, which may be set
  2347. differently from @code{viper-case-fold-search}. Therefore, case-sensitivity
  2348. of mouse search may be different from that of the usual Vi-style search.
  2349. Finally, if the way Viper determines the word to be searched for or to be
  2350. inserted is not what you want, there is a variable,
  2351. @code{viper-surrounding-word-function}, which can be changed to indicate
  2352. another function for snarfing words out of the buffer. The catch is that
  2353. you will then have to write such a function and make it known to your
  2354. Emacs. The function @code{viper-surrounding-word} in @file{viper.el} can be
  2355. used as a guiding example.
  2356. @node Vi Macros
  2357. @section Vi Macros
  2358. @cindex Vi macros
  2359. Viper supports much enhanced Vi-style macros and also facilitates the use
  2360. of Emacs-style macros. To define a temporary macro, it is generally more
  2361. convenient to use Emacs keyboard macro facility. Emacs keyboard macros are
  2362. usually defined anonymously, and the latest macro can be executed by typing
  2363. @kbd{C-x e} (or @kbd{*}, if Viper is in Vi state). If you need to use several
  2364. temporary macros, Viper lets you save them to a
  2365. register (a lowercase letter); such macros can then be executed by typing
  2366. @kbd{@@a} in Vi state (if a macro was previously saved in register
  2367. @kbd{a}).
  2368. @xref{Macros and Registers}, for details.
  2369. If, however, you need to use a macro regularly, it must be given a
  2370. permanent name and saved. Emacs manual explains how to do this, but
  2371. invocation of named Emacs macros is quite different from Vi's. First,
  2372. invocation of permanent Emacs macros takes time because it requires typing
  2373. too many keys (to a Vi user's taste, anyway).
  2374. Second, binding such macros to function keys, for
  2375. fast access, hogs valuable real estate on the keyboard.
  2376. Vi-style macros are better in that respect, since Vi lets the user overload
  2377. the meaning of key sequences: keys typed in fast succession are treated
  2378. specially, if this key sequence is bound to a macro.
  2379. Viper provides Vi-style keyboard macros through the usual Ex commands,
  2380. @kbd{:map} and
  2381. @kbd{:map!}. These macros are much more powerful in Viper than
  2382. they are in the original Vi and in other emulators. This is because Viper
  2383. implements an enhanced vi-style
  2384. interface to the powerful Emacs keyboard macro facility.
  2385. First, any Emacs
  2386. command can be executed while defining a macro, not just the Vi
  2387. commands. In particular, the user can invoke Emacs commands via @kbd{M-x
  2388. command-name} or by pressing various function keys on the keyboard. One
  2389. can even use the mouse, although this is usually not useful and is not
  2390. recommended (and macros defined with the use of the mouse cannot be saved in
  2391. command history and in the startup file, for future use).
  2392. Macros defined by mixing Vi and Emacs commands are represented as
  2393. vectors. So, don't be confused when you see one (usually through the
  2394. history of Ex commands). For instance, if @kbd{gg} is defined by typing
  2395. @kbd{l}, the up-arrow key and @kbd{M-x next-line}, its definition will look
  2396. as follows in Emacs:
  2397. @example
  2398. [l up (meta x) n e x t - l i n e return]
  2399. @end example
  2400. Second, Viper macros are defined in a WYSIWYG style. This means that
  2401. commands are executed as you type them, so you can see precisely what is
  2402. being defined. Third, macros can be bound to arbitrary sequences of keys,
  2403. not just to printable keys. For instance, one can define a macro that will
  2404. be invoked by hitting @kbd{f3} then @kbd{f2} function keys. (The keys
  2405. @kbd{delete} and @kbd{backspace} are excluded; also, a macro invocation
  2406. sequence can't start with @key{ESC}. Some other keys, such as @kbd{f1} and
  2407. @kbd{help}, can't be bound to macros under Emacs, since they
  2408. are bound in @code{key-translation-map}, which overrides any other binding
  2409. the user gives to keys. In general, keys that have a binding in
  2410. @code{key-translation-map} can't be bound to a macro.)
  2411. Fourth, in Viper, one can define macros that are specific to a given
  2412. buffer, a given major mode, or macros that are defined for all buffers. In
  2413. fact, the same macro name can have several different definitions: one
  2414. global, several definitions for various major modes, and
  2415. definitions for various specific buffers. Buffer-specific definitions
  2416. override mode-specific definitions, which, in turn, override global
  2417. definitions.
  2418. As if all that is not enough, Viper (through its interface to Emacs
  2419. macros) lets the user define keyboard macros that ask for confirmation or
  2420. even prompt the user for input and then continue. To do this, one should
  2421. type @kbd{C-x q} (for confirmation) or @kbd{C-u C-x q} (for prompt).
  2422. For details, @pxref{Keyboard Macro Query,,Customization,emacs,The GNU Emacs
  2423. Manual}.
  2424. When the user finishes defining a macro (which is done by typing @kbd{C-x)},
  2425. a departure from Vi), you will be asked whether you want this
  2426. macro to be global, mode-specific, or buffer-specific. You will also be
  2427. given a chance to save the macro in your Viper customization file.
  2428. This is the easiest way to save a macro and make
  2429. it permanently available. If you work your startup files with bare hands,
  2430. here is how Viper saves the above macro so that it will be
  2431. available in Viper's Insert state (and Replace state) in buffer @code{my-buf}
  2432. only:
  2433. @example
  2434. (viper-record-kbd-macro "gg" 'insert-state
  2435. [l up (meta x) n e x t - l i n e return]
  2436. "my-buf")
  2437. @end example
  2438. @noindent
  2439. To do the same for Vi state and all buffers with the major mode
  2440. @code{cc-mode}, use:
  2441. @example
  2442. (viper-record-kbd-macro "gg" 'vi-state
  2443. [l up (meta x) n e x t - l i n e return]
  2444. 'cc-mode)
  2445. @end example
  2446. @noindent
  2447. Both macro names and macro definitions are vectors of symbols that denote
  2448. keys on the keyboard. Some keys, like @kbd{\}, @kbd{ }, or digit-keys must
  2449. be escaped with a backslash. Modified keys are represented as lists. For
  2450. instance, holding Meta and Control and pressing @kbd{f4} is represented as
  2451. @kbd{(control meta f4)}.
  2452. If all members of a vectors are printable characters (or sequences, such as
  2453. @kbd{\e}, @kbd{\t}, for @key{ESC} and @key{TAB}), then they can also be represented as
  2454. strings:
  2455. @example
  2456. (viper-record-kbd-macro "aa" 'vi-state "aaa\e" "my-buffer")
  2457. @end example
  2458. @noindent
  2459. Thus, typing @kbd{aa} fast in Vi state will switch Viper to Insert state
  2460. (due to the first @kbd{a}), insert @kbd{aa}, and then it will switch back to Vi
  2461. state. All this will take effect only in the buffer named @code{my-buffer}.
  2462. Note that the last argument to @code{viper-record-kbd-macro} must be either a
  2463. string (a buffer name), a symbol representing a major mode, or @code{t};
  2464. the latter says that the macro is to be defined for all buffers
  2465. (which is how macros are defined in original Vi).
  2466. For convenience, Viper also lets you define Vi-style macros in its Emacs
  2467. state. There is no Ex command, like @kbd{:map} and @kbd{:map!} for doing
  2468. this, but the user can include such a macro in the Viper customization file.
  2469. The only thing is that the @code{viper-record-kbd-macro} command should specify
  2470. @code{emacs-state} instead of @code{vi-state} or @code{insert-state}.
  2471. The user can get rid of a macro either by using the Ex commands @kbd{:unmap}
  2472. and @kbd{:unmap!} or by issuing a call to @code{viper-unrecord-kbd-macro}.
  2473. The latter is more powerful, since it can delete macros even in
  2474. @code{emacs-state}. However, @code{viper-unrecord-kbd-macro} is usually
  2475. needed only when the user needs to get rid of the macros that are already
  2476. predefined in Viper.
  2477. The syntax is:
  2478. @findex @code{viper-unrecord-kbd-macro}
  2479. @example
  2480. (viper-unrecord-kbd-macro macro state)
  2481. @end example
  2482. @noindent
  2483. The second argument must be @code{vi-state}, @code{insert-state}, or
  2484. @code{emacs-state}. The first argument is a name of a macro. To avoid
  2485. mistakes in specifying names of existing macros, type @kbd{M-x
  2486. viper-describe-kbd-macros} and use a name from the list displayed by this
  2487. command.
  2488. If an error occurs during macro definition, Emacs
  2489. aborts the process, and it must be repeated. This is analogous to Vi,
  2490. except that in Vi the user doesn't know there is an error until the macro is
  2491. actually run. All that means that in order for a definition to be
  2492. successful, the user must do some simple planning of the process in
  2493. advance, to avoid errors. For instance, if you want to map @kbd{gg} to
  2494. @kbd{llll} in Vi state, you must make sure that there is enough room on the
  2495. current line. Since @kbd{l} moves the cursor forward, it may signal an
  2496. error on reaching the end of line, which will abort the definition.
  2497. These precautions are necessary only when defining macros; they will help
  2498. avoid the need to redo the job. When macros are actually run, an error
  2499. during the execution will simply terminate the current execution
  2500. (but the macro will remain mapped).
  2501. A macro name can be a string of characters or a vector of keys.
  2502. The latter makes it possible to define macros bound to, say, double-hits
  2503. on a function key, such as @kbd{up} or @kbd{f13}.
  2504. This is very useful if you run out of function keys on your keyboard; it
  2505. makes Viper macro facility a @emph{keyboard doubler}, so to speak.
  2506. Elsewhere (@xref{Key Bindings}, for details), we review
  2507. the standard Emacs mechanism for binding function keys to commands.
  2508. For instance,
  2509. @example
  2510. (global-set-key [f13] 'repeat-complex-command)
  2511. @end example
  2512. @noindent
  2513. binds the key f13 to the Emacs function that repeats the last minibuffer
  2514. command. Under Viper, however, you may still use this key for additional
  2515. purposes, if you bind, say, a double-hitting action for that key to some
  2516. other function. Emacs doesn't allow the user to do that, but Viper does
  2517. this through its keyboard macro facility. To do this, type @kbd{:map }
  2518. first. When you are asked to enter a macro name, hit f13 twice, followed by
  2519. @key{RET} or @key{SPC}.
  2520. Emacs will now start the mapping process by actually executing
  2521. Vi and Emacs commands, so that you could see what will happen each time the
  2522. macro is executed. Suppose now we wanted to bind the key sequence
  2523. @kbd{f13 f13} to the command @code{eval-last-sexp}. To accomplish this, we
  2524. can type @kbd{M-x eval-last-sexp} followed by @kbd{C-x )}.
  2525. If you answer positively to Viper's offer to save this macro in your
  2526. Viper customization file for future uses, the following will be inserted
  2527. in that file:
  2528. @example
  2529. (viper-record-kbd-macro [f16 f16] 'vi-state
  2530. [(meta x) e v a l - l a s t - s e x p]
  2531. 'lisp-interaction-mode)
  2532. @end example
  2533. To illustrate the above point, Viper provides two canned macros, which, by
  2534. default, are bound to @kbd{[f12 \1]} and @kbd{[f12 \2]} (invoked by typing
  2535. @kbd{f12} then @kbd{1} and @kbd{2}, respectively). These macros are useful
  2536. shortcuts to Viper's command ring history. The first macro will execute the
  2537. second-last destructive command (the last one is executed by @kbd{.}, as
  2538. usual). The second macro executes the third-last command.
  2539. If you need to go deeper into the command history, you will have to use
  2540. other commands, as described earlier in this section; or you can bind,
  2541. say, @kbd{f12 \3} like this:
  2542. @example
  2543. (viper-record-kbd-macro [f12 \3] 'vi-state
  2544. [(meta x) r e p e a t - f r o m - h i s t o r y]
  2545. t)
  2546. @end example
  2547. Note that even though the macro uses the function key @kbd{f12}, the key is
  2548. actually free and can still be bound to some Emacs function via
  2549. @code{define-key} or @code{global-set-key}.
  2550. Viper allows the user to define macro names that are prefixes of other macros.
  2551. For instance, one can define @kbd{[[} and @kbd{[[[[} to be macros.
  2552. If you type the exact sequence of such keys and then pause, Viper will
  2553. execute the right macro. However, if you don't pause and, say, type
  2554. @kbd{[[[[text} then the conflict is resolved as follows. If only one of the
  2555. key sequences, @kbd{[[} or @kbd{[[[[} has a definition applicable to the
  2556. current buffer, then, in fact, there is no conflict and the right macro
  2557. will be chosen. If both have applicable definitions, then the first one
  2558. found will be executed. Usually this is the macro with a shorter name. So,
  2559. in our case, @kbd{[[[[text} will cause the macro @kbd{[[} to be executed
  2560. twice and then the remaining keys, @kbd{t e x t}, will be processed.
  2561. When defining macros using @kbd{:map} or @kbd{:map!}, the user enters
  2562. the actually keys to be used to invoke the macro. For instance, you
  2563. should hit the actual key @kbd{f6} if it is to be part of a macro
  2564. name; you do @emph{not} write @kbd{f 6}. When entering keys, Viper
  2565. displays them as strings or vectors (e.g., @code{"abc"} or @code{[f6
  2566. f7 a]}). The same holds for unmapping. Hitting @key{TAB} while
  2567. typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command will
  2568. cause name completion. Completions are displayed as strings or
  2569. vectors. However, as before, you don't actually type @samp{"},
  2570. @samp{[}, or @samp{]} that appear in the completions. These are
  2571. meta-symbols that indicate whether the corresponding macro name is a
  2572. vector or a string.
  2573. One last difference from Vi: Vi-style keyboard macros cannot be defined in
  2574. terms of other Vi-style keyboard macros (but named Emacs macros are OK).
  2575. More precisely, while defining or executing a macro, the special meaning
  2576. of key sequences (as Vi macros) is ignored.
  2577. This is because it is all too easy to create an infinite loop in this way.
  2578. Since Viper macros are much more powerful than Vi's it is impossible to
  2579. detect such loops. In practice, this is not really a limitation but,
  2580. rather, a feature.
  2581. We should also note that Vi macros are disabled in the minibuffer, which
  2582. helps keep some potential troubles away.
  2583. The rate at which the user must type keys in order for them to be
  2584. recognized as a timeout macro is controlled by the variable
  2585. @code{viper-fast-keyseq-timeout}, which defaults to 200 milliseconds.
  2586. For the most part, Viper macros defined in the Viper customization file can
  2587. be shared between X and TTY modes.
  2588. The problem with TTY may be that the function keys there generate sequences
  2589. of events instead of a single event (as under a window system).
  2590. Emacs maps some of these sequences back to the logical keys
  2591. (e.g., the sequences generated by the arrow keys are mapped to @kbd{up},
  2592. @kbd{left}, etc.). However, not all function keys are mapped in this way.
  2593. Macros that are bound to key sequences that contain such unmapped function
  2594. keys have to be redefined for TTY's (and possibly for every type of TTY you
  2595. may be using). To do this, start Emacs on an appropriate TTY device and
  2596. define the macro using @kbd{:map}, as usual.
  2597. @findex @code{viper-describe-kbd-macros}
  2598. Finally, Viper provides a function that conveniently displays all macros
  2599. currently defined. To see all macros along with their definitions, type
  2600. @kbd{M-x viper-describe-kbd-macros}.
  2601. @node Commands
  2602. @chapter Commands
  2603. This section is a semi-automatically bowdlerized version of the Vi
  2604. reference created by @* @samp{maart@@cs.vu.nl} and others. It can be
  2605. found on the Vi archives. This reference has been adapted for Viper.
  2606. @menu
  2607. * Groundwork:: Textual Conventions and Viper basics
  2608. * Text Handling:: Moving, Editing, Undoing.
  2609. * Display:: Scrolling.
  2610. * File and Buffer Handling:: Editing, Writing and Quitting.
  2611. * Mapping:: Mapping Keys, Keyboard Macros
  2612. * Shell Commands:: Accessing Shell Commands, Processing Text
  2613. * Options:: Ex options, the @kbd{:set} commands
  2614. * Emacs Related Commands:: Meta Keys, Windows
  2615. * Mouse-bound Commands:: Search and insertion of text
  2616. @end menu
  2617. @node Groundwork
  2618. @section Groundwork
  2619. The VI command set is based on the idea of combining motion commands
  2620. with other commands. The motion command is used as a text region
  2621. specifier for other commands.
  2622. We classify motion commands into @dfn{point commands} and
  2623. @dfn{line commands}.
  2624. @cindex point commands
  2625. The point commands are:
  2626. @quotation
  2627. @kbd{h}, @kbd{l}, @kbd{0}, @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B},
  2628. @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f},
  2629. @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^}
  2630. @end quotation
  2631. @cindex line commands
  2632. The line commands are:
  2633. @quotation
  2634. @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{},
  2635. @kbd{@}}, @kbd{G}, @kbd{'}, @kbd{[[}, @kbd{]]}, @kbd{[]}
  2636. @end quotation
  2637. @noindent
  2638. Text Deletion Commands (@pxref{Deleting Text}), Change commands
  2639. (@pxref{Changing Text}), even Shell Commands (@pxref{Shell Commands})
  2640. use these commands to describe a region of text to operate on.
  2641. @cindex r and R region specifiers
  2642. Viper adds two region descriptors, @kbd{r} and @kbd{R}. These describe
  2643. the Emacs regions (@pxref{Basics}), but they are not movement commands.
  2644. The command description uses angle brackets @samp{<>} to indicate
  2645. metasyntactic variables, since the normal conventions of using simple
  2646. text can be confusing with Viper where the commands themselves are
  2647. characters. Watch out where @kbd{<} shift commands and @kbd{<count>} are
  2648. mentioned together!!!
  2649. @kindex <move>
  2650. @kindex <a-z>
  2651. @kindex <address>
  2652. @cindex <move>
  2653. @cindex <a-z>
  2654. @cindex <address>
  2655. @cindex movements
  2656. @samp{<move>} refers to the above movement commands, and @samp{<a-z>}
  2657. refers to registers or textmarkers from @samp{a} to @samp{z}. Note
  2658. that the @samp{<move>} is described by full move commands, that is to
  2659. say they will take counts, and otherwise behave like normal move commands.
  2660. @cindex Ex addresses
  2661. @samp{<address>} refers to Ex line addresses, which include
  2662. @table @kbd
  2663. @item .@: <No address>
  2664. Current line
  2665. @item .+n .-n
  2666. Add or subtract for current line
  2667. @item number
  2668. Actual line number, use @kbd{.=} to get the line number
  2669. @item '<a-z>
  2670. Textmarker
  2671. @item $
  2672. Last line
  2673. @item x,y
  2674. Where x and y are one of the above
  2675. @item %
  2676. @cindex % (Ex address)
  2677. For the whole file, same as (1,$).
  2678. @item /<pat>/
  2679. @itemx ?<pat>?
  2680. Next or previous line with pattern <pat>.
  2681. Note that the pattern is allowed to contain newline character (inserted as
  2682. @kbd{C-qC-j}). Therefore, one can search for patterns that span several
  2683. lines.
  2684. @end table
  2685. @cindex % (Current file)
  2686. Note that @samp{%} is used in Ex commands @kbd{:e} and @kbd{:r <shell-cmd>}
  2687. to mean current file. If you want a @samp{%} in your command, it must be
  2688. escaped as @samp{\%}. Note that @kbd{:w} and the regular @kbd{:r <file>}
  2689. command doesn't support the meta symbols @samp{%} and @samp{#}, because
  2690. file history is a better mechanism.
  2691. @cindex # (Previous file)
  2692. Similarly, @samp{#} expands to the previous file. The previous file is
  2693. the first file in @kbd{:args} listing. This defaults to previous window
  2694. in the VI sense if you have one window only.
  2695. @kindex <args>
  2696. @kindex <cmd>
  2697. @cindex <args>
  2698. @cindex <cmd>
  2699. @noindent
  2700. Others like @samp{<args> -- arguments}, @samp{<cmd> -- command} etc.
  2701. should be fairly obvious.
  2702. @noindent
  2703. Common characters referred to include:
  2704. @table @kbd
  2705. @item <sp>
  2706. Space
  2707. @item <ht>
  2708. Tab
  2709. @item <lf>
  2710. Linefeed
  2711. @item <esc>
  2712. Escape
  2713. @item <cr>
  2714. Return, Enter
  2715. @end table
  2716. @cindex <cr>
  2717. @cindex <esc>
  2718. @cindex <lf>
  2719. @cindex <ht>
  2720. @cindex <sp>
  2721. @cindex words
  2722. @cindex WORDS
  2723. @cindex char
  2724. @cindex CHAR
  2725. We also use @samp{word} for alphanumeric/non-alphanumeric words, and
  2726. @samp{WORD} for whitespace delimited words. @samp{char} refers to any
  2727. @acronym{ASCII} character, @samp{CHAR} to non-whitespace character.
  2728. Brackets @samp{[]} indicate optional parameters; @samp{<count>} also
  2729. optional, usually defaulting to 1. Brackets are elided for
  2730. @samp{<count>} to eschew obfuscation.
  2731. Viper's idea of Vi's words is slightly different from Vi. First, Viper
  2732. words understand Emacs symbol tables. Therefore, all symbols declared to be
  2733. alphanumeric in a symbol table can automatically be made part of the Viper
  2734. word. This is useful when, for instance, editing text containing European,
  2735. Cyrillic, Japanese, etc., texts.
  2736. Second, Viper lets you depart from Vi's idea of a word by changing the a
  2737. syntax preference via the customization widget (the variable
  2738. @code{viper-syntax-preference}) or by executing
  2739. @code{viper-set-syntax-preference} interactively.
  2740. By default, Viper syntax preference is @code{reformed-vi}, which means that
  2741. Viper considers only those symbols to be part of a word that are specified
  2742. as word-symbols by the current Emacs syntax table (which may be different
  2743. for different major modes) plus the underscore symbol @kbd{_}, minus the
  2744. symbols that are not considered words in Vi (e.g., @samp{,}, @samp{;},
  2745. etc.), but may be
  2746. considered as word-symbols by various Emacs major modes. Reformed-Vi works
  2747. very close to Vi, and it also recognizes words in other
  2748. alphabets. Therefore, this is the most appropriate mode for editing text
  2749. and is likely to fit all your needs.
  2750. You can also set Viper syntax preference to @code{strict-vi}, which would
  2751. cause Viper to view all non-English letters as non-word-symbols.
  2752. You can also specify @code{emacs} as your preference, which would
  2753. make Viper use exactly the same notion of a word as Emacs does. In
  2754. particular, the underscore may not be part of a word in some major modes.
  2755. Finally, if @code{viper-syntax-preference} is set to @code{extended}, Viper
  2756. words would consist of characters that are classified as alphanumeric
  2757. @emph{or} as parts of symbols. This is convenient for editing programs.
  2758. @code{viper-syntax-preference} is a local variable, so it can have different
  2759. values for different major modes. For instance, in programming modes it can
  2760. have the value @code{extended}. In text modes where words contain special
  2761. characters, such as European (non-English) letters, Cyrillic letters, etc.,
  2762. the value can be @code{reformed-vi} or @code{emacs}.
  2763. If you consider using different syntactic preferences for different major
  2764. modes, you should execute, for example,
  2765. @example
  2766. (viper-set-syntax-preference nil "extended")
  2767. @end example
  2768. in the appropriate major mode hooks.
  2769. @vindex @code{viper-syntax-preference}
  2770. @findex @code{viper-set-syntax-preference}
  2771. @cindex syntax table
  2772. The above discussion concerns only the movement commands. In regular
  2773. expressions, words remain the same as in Emacs. That is, the expressions
  2774. @code{\w}, @code{\>}, @code{\<}, etc., use Emacs's idea of what is a word,
  2775. and they don't look into the value of variable
  2776. @code{viper-syntax-preference}. This is because Viper avoids changing
  2777. syntax tables in order to not thwart the various major modes that set these
  2778. tables.
  2779. The usual Emacs convention is used to indicate Control Characters, i.e.,
  2780. C-h for Control-h. @emph{Do not confuse this with a sequence of separate
  2781. characters
  2782. C, -, h!!!} The @kbd{^} is itself, never used to indicate a
  2783. Control character.
  2784. Finally, we note that Viper's Ex-style commands can be made to work on the
  2785. current Emacs region. This is done by typing a digit argument before
  2786. @kbd{:}. For instance, typing @kbd{1:} will prompt you with something like
  2787. @emph{:123,135}, assuming that the current region starts at line 123 and
  2788. ends at line 135. There is no need to type the line numbers, since Viper
  2789. inserts them automatically in front of the Ex command.
  2790. @cindex Ex commands
  2791. @node Text Handling
  2792. @section Text Handling
  2793. @menu
  2794. * Move Commands:: Moving, Searching
  2795. * Marking:: Textmarkers in Viper and the Emacs Mark.
  2796. * Appending Text:: Text insertion, Shifting, Putting
  2797. * Editing in Insert State:: Autoindent, Quoting etc.
  2798. * Deleting Text:: Deleting
  2799. * Changing Text:: Changing, Replacement, Joining
  2800. * Search and Replace:: Searches, Query Replace, Pattern Commands
  2801. * Yanking:: Yanking, Viewing Registers
  2802. * Undoing:: Multiple Undo, Backups
  2803. @end menu
  2804. @node Move Commands
  2805. @subsection Move Commands
  2806. @cindex movement commands
  2807. @cindex searching
  2808. @cindex textmarkers
  2809. @cindex markers
  2810. @cindex column movement
  2811. @cindex paragraphs
  2812. @cindex headings
  2813. @cindex sections
  2814. @cindex sentences
  2815. @cindex matching parens
  2816. @cindex paren matching
  2817. @table @kbd
  2818. @item <count> h C-h
  2819. <count> chars to the left.
  2820. @item <count> j <lf> C-n
  2821. <count> lines downward.
  2822. @item <count> l <sp>
  2823. <count> chars to the right.
  2824. @item <count> k C-p
  2825. <count> lines upward.
  2826. @item <count> $
  2827. To the end of line <count> from the cursor.
  2828. @item <count> ^
  2829. To the first CHAR <count> @minus{} 1 lines lower.
  2830. @item <count> -
  2831. To the first CHAR <count> lines higher.
  2832. @item <count> + <cr>
  2833. To the first CHAR <count> lines lower.
  2834. @item 0
  2835. To the first char of the line.
  2836. @item <count> |
  2837. To column <count>
  2838. @item <count> f<char>
  2839. <count> <char>s to the right (find).
  2840. @item <count> t<char>
  2841. Till before <count> <char>s to the right.
  2842. @item <count> F<char>
  2843. <count> <char>s to the left.
  2844. @item <count> T<char>
  2845. Till after <count> <char>s to the left.
  2846. @item <count> ;
  2847. Repeat latest @kbd{f t F T} <count> times.
  2848. @item <count> ,
  2849. Repeat latest @kbd{f t F T}
  2850. <count> times in opposite direction.
  2851. @item <count> w
  2852. <count> words forward.
  2853. @item <count> W
  2854. <count> WORDS forward.
  2855. @item <count> b
  2856. <count> words backward.
  2857. @item <count> B
  2858. <count> WORDS backward.
  2859. @item <count> e
  2860. To the end of word <count> forward.
  2861. @item <count> E
  2862. To the end of WORD <count> forward.
  2863. @item <count> G
  2864. Go to line <count> (default end-of-file).
  2865. @item <count> H
  2866. To line <count> from top of the screen (home).
  2867. @item <count> L
  2868. To line <count> from bottom of the screen (last).
  2869. @item M
  2870. To the middle line of the screen.
  2871. @item <count> )
  2872. <count> sentences forward.
  2873. @item <count> (
  2874. <count> sentences backward.
  2875. @item <count> @}
  2876. <count> paragraphs forward.
  2877. @item <count> @{
  2878. <count> paragraphs backward.
  2879. @item <count> ]]
  2880. To the <count>th heading.
  2881. @item <count> [[
  2882. To the <count>th previous heading.
  2883. @item <count> []
  2884. To the end of <count>th heading.
  2885. @item m<a-z>
  2886. Mark the cursor position with a letter.
  2887. @item `<a-z>
  2888. To the mark.
  2889. @item '<a-z>
  2890. To the first CHAR of the line with the mark.
  2891. @item [<a-z>
  2892. Show contents of textmarker.
  2893. @item ]<a-z>
  2894. Show contents of register.
  2895. @item ``
  2896. To the cursor position before the latest absolute
  2897. jump (of which are examples @kbd{/} and @kbd{G}).
  2898. @item ''
  2899. To the first CHAR of the line on which the cursor
  2900. was placed before the latest absolute jump.
  2901. @item <count> /<string>
  2902. To the <count>th occurrence of <string>.
  2903. @item <count> /<cr>
  2904. To the <count>th occurrence of <string> from previous @kbd{/ or ?}.
  2905. @item <count> ?<string>
  2906. To the <count>th previous occurrence of <string>.
  2907. @item <count> ?<cr>
  2908. To the <count>th previous occurrence of <string> from previous @kbd{?@: or /}.
  2909. @item n
  2910. Repeat latest @kbd{/} @kbd{?} (next).
  2911. @item N
  2912. Repeat latest search in opposite direction.
  2913. @item C-c /
  2914. Without a prefix argument, this command toggles
  2915. case-sensitive/case-insensitive search modes and plain vanilla/regular
  2916. expression search. With the prefix argument 1, i.e.,
  2917. @kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2,
  2918. toggles plain vanilla search and search using
  2919. regular expressions. @xref{Viper Specials}, for alternative ways to invoke
  2920. this function.
  2921. @cindex vanilla search
  2922. @cindex case-sensitive search
  2923. @cindex case-insensitive search
  2924. @item %
  2925. Find the next bracket/parenthesis/brace and go to its match.
  2926. By default, Viper ignores brackets/parentheses/braces that occur inside
  2927. parentheses. You can change this by setting
  2928. @code{viper-parse-sexp-ignore-comments} to @code{nil} in your Viper
  2929. customization file.
  2930. This option can also be toggled interactively if you quickly hit @kbd{%%%}.
  2931. This latter feature is implemented as a vi-style keyboard macro. If you
  2932. don't want this macro, put
  2933. @example
  2934. (viper-set-parsing-style-toggling-macro 'undefine)
  2935. @end example
  2936. @findex @code{viper-set-parsing-style-toggling-macro}
  2937. in your Viper customization file.
  2938. @end table
  2939. @kindex @kbd{%}
  2940. @kindex @kbd{C-c /}
  2941. @kindex @kbd{N}
  2942. @kindex @kbd{n}
  2943. @kindex @kbd{?<cr>}
  2944. @kindex @kbd{/<cr>}
  2945. @kindex @kbd{?<string>}
  2946. @kindex @kbd{/<string>}
  2947. @kindex @kbd{''}
  2948. @kindex @kbd{``}
  2949. @kindex @kbd{]<a-z>}
  2950. @kindex @kbd{[<a-z>}
  2951. @kindex @kbd{'<a-z>}
  2952. @kindex @kbd{`<a-z>}
  2953. @kindex @kbd{m<a-z>}
  2954. @kindex @kbd{[]}
  2955. @kindex @kbd{[[}
  2956. @kindex @kbd{]]}
  2957. @kindex @kbd{@{}
  2958. @kindex @kbd{@}}
  2959. @kindex @kbd{(}
  2960. @kindex @kbd{)}
  2961. @kindex @kbd{M}
  2962. @kindex @kbd{L}
  2963. @kindex @kbd{H}
  2964. @kindex @kbd{G}
  2965. @kindex @kbd{E}
  2966. @kindex @kbd{e}
  2967. @kindex @kbd{B}
  2968. @kindex @kbd{b}
  2969. @kindex @kbd{W}
  2970. @kindex @kbd{w}
  2971. @kindex @kbd{,}
  2972. @kindex @kbd{;}
  2973. @kindex @kbd{T<char>}
  2974. @kindex @kbd{F<char>}
  2975. @kindex @kbd{t<char>}
  2976. @kindex @kbd{f<char>}
  2977. @kindex @kbd{|}
  2978. @kindex @kbd{0}
  2979. @kindex @kbd{<cr>}
  2980. @kindex @kbd{+}
  2981. @kindex @kbd{-}
  2982. @kindex @kbd{^}
  2983. @kindex @kbd{$}
  2984. @kindex @kbd{C-p}
  2985. @kindex @kbd{<lf>}
  2986. @kindex @kbd{<sp>}
  2987. @kindex @kbd{C-n}
  2988. @kindex @kbd{C-h}
  2989. @kindex @kbd{h}
  2990. @kindex @kbd{j}
  2991. @kindex @kbd{k}
  2992. @kindex @kbd{l}
  2993. @vindex @code{viper-parse-sexp-ignore-comments}
  2994. @node Marking
  2995. @subsection Marking
  2996. Emacs mark is referred to in the region specifiers @kbd{r} and @kbd{R}.
  2997. @xref{Emacs Preliminaries}, and @xref{Basics}, for explanation. Also
  2998. see @ref{Mark,,Mark,emacs,The GNU Emacs manual}, for an explanation of
  2999. the Emacs mark ring.
  3000. @cindex marking
  3001. @table @kbd
  3002. @item m<a-z>
  3003. Mark the current file and position with the specified letter.
  3004. @item m .
  3005. Set the Emacs mark (@pxref{Emacs Preliminaries}) at point.
  3006. @item m ^
  3007. Set the Emacs mark (@pxref{Emacs Preliminaries}) back to where it was last
  3008. set with the @kbd{m.} command. This is useful when you set the mark with
  3009. @kbd{m.}, but then some other command (such as @kbd{L} or @kbd{G}) changes
  3010. it in a way that you didn't like.
  3011. @item m <
  3012. Set the Emacs mark at beginning of buffer.
  3013. @item m >
  3014. Set the Emacs mark at end of buffer.
  3015. @item m ,
  3016. Jump to the Emacs mark.
  3017. @item :mark <char>
  3018. Mark position with text marker named <char>. This is an Ex command.
  3019. @item :k <char>
  3020. Same as @kbd{:mark}.
  3021. @item ``
  3022. Exchange point and mark.
  3023. @item ''
  3024. Exchange point and mark and go to the first CHAR on line.
  3025. @item '<a-z>
  3026. Go to specified Viper mark.
  3027. @item `<a-z>
  3028. Go to specified Viper mark and go to the first CHAR on line.
  3029. @end table
  3030. @kindex @kbd{m<a-z>}
  3031. @kindex @kbd{m.}
  3032. @kindex @kbd{m>}
  3033. @kindex @kbd{m<}
  3034. @kindex @kbd{m,}
  3035. @kindex @kbd{m^}
  3036. @findex @kbd{Ex mark}
  3037. @findex @kbd{Ex k}
  3038. @kindex @kbd{''}
  3039. @kindex @kbd{``}
  3040. @kindex @kbd{`<a-z>}
  3041. @kindex @kbd{'<a-z>}
  3042. @node Appending Text
  3043. @subsection Appending Text
  3044. @xref{Options}, to see how to change tab and shiftwidth size. See the GNU
  3045. Emacs manual, or try @kbd{C-ha tabs} (If you have turned Emacs help on).
  3046. Check out the variable @code{indent-tabs-mode} to put in just spaces.
  3047. Also see options for word-wrap.
  3048. @cindex inserting
  3049. @cindex appending
  3050. @cindex paste
  3051. @cindex put
  3052. @table @kbd
  3053. @item <count> a
  3054. <count> times after the cursor.
  3055. @item <count> A
  3056. <count> times at the end of line.
  3057. @item <count> i
  3058. <count> times before the cursor (insert).
  3059. @item <count> I
  3060. <count> times before the first CHAR of the line
  3061. @item <count> o
  3062. On a new line below the current (open).
  3063. The count is only useful on a slow terminal.
  3064. @item <count> O
  3065. On a new line above the current.
  3066. The count is only useful on a slow terminal.
  3067. @item <count> ><move>
  3068. Shift the lines described by <count><move> one
  3069. shiftwidth to the right (layout!).
  3070. @item <count> >>
  3071. Shift <count> lines one shiftwidth to the right.
  3072. @item <count> ["<a-z1-9>]p
  3073. Put the contents of the (default undo) buffer
  3074. <count> times after the cursor. The register will
  3075. be automatically down-cased.
  3076. @item <count> ["<a-z1-9>]P
  3077. Put the contents of the (default undo) buffer
  3078. <count> times before the cursor. The register will
  3079. @item [<a-z>
  3080. Show contents of textmarker.
  3081. @item ]<a-z>
  3082. Show contents of register.
  3083. @item <count> .
  3084. Repeat previous command <count> times. For destructive
  3085. commands as well as undo.
  3086. @item f1 1 and f1 2
  3087. While @kbd{.} repeats the last destructive command,
  3088. these two macros repeat the second-last and the third-last destructive
  3089. commands. @xref{Vi Macros}, for more information on Vi macros.
  3090. @item C-c M-p and C-c M-n
  3091. In Vi state,
  3092. these commands help peruse the history of Vi's destructive commands.
  3093. Successive typing of @kbd{C-c M-p} causes Viper to search the history in
  3094. the direction
  3095. of older commands, while hitting @kbd{C-c M-n} does so in reverse
  3096. order. Each command in the history is displayed in the minibuffer. The
  3097. displayed command can
  3098. then be executed by typing a period.
  3099. Since typing the above sequences of keys may be tedious, the
  3100. functions doing the perusing can be bound to unused keyboard keys in the
  3101. Viper customization file. @xref{Viper Specials}, for details.
  3102. @end table
  3103. @kindex @kbd{C-c M-p}
  3104. @kindex @kbd{C-c M-n}
  3105. @kindex @kbd{.}
  3106. @kindex @kbd{]<a-z>}
  3107. @kindex @kbd{[<a-z>}
  3108. @kindex @kbd{P}
  3109. @kindex @kbd{p}
  3110. @kindex @kbd{"<a-z1-9>p}
  3111. @kindex @kbd{"<a-z1-9>P}
  3112. @kindex @kbd{>>}
  3113. @kindex @kbd{><move>}
  3114. @kindex @kbd{O}
  3115. @kindex @kbd{o}
  3116. @kindex @kbd{i}
  3117. @kindex @kbd{A}
  3118. @kindex @kbd{a}
  3119. @node Editing in Insert State
  3120. @subsection Editing in Insert State
  3121. Minibuffer can be edited similarly to Insert state, and you can switch
  3122. between Insert/Replace/Vi states at will.
  3123. Some users prefer plain Emacs feel in the minibuffer. To this end, set
  3124. @var{viper-vi-style-in-minibuffer} to @code{nil}.
  3125. @cindex Insert state
  3126. @table @kbd
  3127. @item C-v
  3128. Deprive the next char of its special meaning (quoting).
  3129. @item C-h
  3130. One char back.
  3131. @item C-w
  3132. One word back.
  3133. @item C-u
  3134. Back to the begin of the change on the
  3135. current line.
  3136. @end table
  3137. @kindex @kbd{C-u}
  3138. @kindex @kbd{C-w}
  3139. @kindex @kbd{C-v}
  3140. @node Deleting Text
  3141. @subsection Deleting Text
  3142. There is one difference in text deletion that you should be
  3143. aware of. This difference comes from Emacs and was adopted in Viper
  3144. because we find it very useful. In Vi, if you delete a line, say, and then
  3145. another line, these two deletions are separated and are put back
  3146. separately if you use the @samp{p} command. In Emacs (and Viper), successive
  3147. series of deletions that are @emph{not interrupted} by other commands are
  3148. lumped together, so the deleted text gets accumulated and can be put back
  3149. as one chunk. If you want to break a sequence of deletions so that the
  3150. newly deleted text could be put back separately from the previously deleted
  3151. text, you should perform a non-deleting action, e.g., move the cursor one
  3152. character in any direction.
  3153. @cindex shifting text
  3154. @table @kbd
  3155. @item <count> x
  3156. Delete <count> chars under and after the cursor.
  3157. @item <count> X
  3158. Delete <count> chars before the cursor.
  3159. @item <count> d<move>
  3160. Delete from point to endpoint of <count><move>.
  3161. @item <count> dd
  3162. Delete <count> lines.
  3163. @item D
  3164. The rest of the line.
  3165. @item <count> <<move>
  3166. Shift the lines described by <count><move> one
  3167. shiftwidth to the left (layout!).
  3168. @item <count> <<
  3169. Shift <count> lines one shiftwidth to the left.
  3170. @end table
  3171. @kindex @kbd{<<}
  3172. @kindex @kbd{<<move>}
  3173. @kindex @kbd{D}
  3174. @kindex @kbd{dd}
  3175. @kindex @kbd{d<move>}
  3176. @kindex @kbd{X}
  3177. @kindex @kbd{x}
  3178. @node Changing Text
  3179. @subsection Changing Text
  3180. @cindex joining lines
  3181. @cindex changing case
  3182. @cindex quoting regions
  3183. @cindex substitution
  3184. @table @kbd
  3185. @item <count> r<char>
  3186. Replace <count> chars by <char>; no <esc>.
  3187. @item <count> R
  3188. Overwrite the rest of the line,
  3189. appending change @var{count} @minus{} 1 times.
  3190. @item <count> s
  3191. Substitute <count> chars.
  3192. @item <count> S
  3193. Change <count> lines.
  3194. @item <count> c<move>
  3195. Change from begin to endpoint of <count><move>.
  3196. @item <count> cc
  3197. Change <count> lines.
  3198. @item <count> C
  3199. The rest of the line and <count> @minus{} 1 next lines.
  3200. @item <count> =<move>
  3201. Reindent the region described by move.
  3202. @item <count> ~
  3203. Switch lower and upper cases.
  3204. @item <count> J
  3205. Join <count> lines (default 2).
  3206. @item :[x,y]s/<pat>/<repl>/<f>
  3207. Substitute (on lines x through y) the pattern
  3208. <pat> (default the last pattern) with <repl>. Useful
  3209. flags <f> are @samp{g} for @samp{global} (i.e., change every
  3210. non-overlapping occurrence of <pat>) and @samp{c} for
  3211. @samp{confirm} (type @samp{y} to confirm a particular
  3212. substitution, else @samp{n} ). Instead of @kbd{/} any
  3213. punctuation CHAR unequal to <space> <tab> and <lf> can be used as
  3214. delimiter.
  3215. In Emacs, @samp{\&} stands for the last matched expression, so
  3216. @kbd{s/[ab]+/\&\&/} will double the string matched by @kbd{[ab]}.
  3217. Viper doesn't treat @samp{&} specially, unlike Vi: use @samp{\&} instead.
  3218. Viper does not parse search patterns and does not expand special symbols
  3219. found there (e.g., @samp{~} is not expanded to the result of the previous
  3220. substitution).
  3221. Note: @emph{The newline character (inserted as @kbd{C-qC-j})
  3222. can be used in <repl>}.
  3223. @item :[x,y]copy [z]
  3224. Copy text between @kbd{x} and @kbd{y} to the position after @kbd{z}.
  3225. @item :[x,y]t [z]
  3226. Same as @kbd{:copy}.
  3227. @item :[x,y]move [z]
  3228. Move text between @kbd{x} and @kbd{y} to the position after @kbd{z}.
  3229. @item &
  3230. Repeat latest Ex substitute command, e.g.,
  3231. @kbd{:s/wrong/right}.
  3232. @item :x,yp
  3233. @itemx :g/Pat/p
  3234. @itemx :v/Pat/p
  3235. The above commands display certain buffer lines in a
  3236. temporary buffer. The first form above displays the buffer lines between
  3237. @kbd{x} and @kbd{y}. The second displays the lines of the buffer, which
  3238. match a given pattern. The third form displays the lines that do @emph{not}
  3239. match the given pattern.
  3240. @item #c<move>
  3241. Change upper-case characters in the region to lower-case.
  3242. @item #C<move>
  3243. Change lower-case characters in the region to upper-case.
  3244. @item #q<move>
  3245. Insert specified string at the beginning of each line in the region
  3246. @item C-c M-p and C-c M-n
  3247. In Insert and Replace states, these keys are bound to commands that peruse
  3248. the history of the text
  3249. previously inserted in other insert or replace commands. By repeatedly typing
  3250. @kbd{C-c M-p} or @kbd{C-c M-n}, you will cause Viper to
  3251. insert these previously used strings one by one.
  3252. When a new string is inserted, the previous one is deleted.
  3253. In Vi state, these keys are bound to functions that peruse the history of
  3254. destructive Vi commands.
  3255. @xref{Viper Specials}, for details.
  3256. @end table
  3257. @kindex @kbd{C-c M-p}
  3258. @kindex @kbd{C-c M-n}
  3259. @kindex @kbd{#q<move> }
  3260. @kindex @kbd{#C<move>}
  3261. @kindex @kbd{#c<move>}
  3262. @kindex @kbd{&}
  3263. @kindex @kbd{\&}
  3264. @findex @kbd{Ex substitute/<pat>/<repl>/<f>}
  3265. @findex @kbd{Ex s/<pat>/<repl>/<f>}
  3266. @findex @kbd{Ex copy [z]}
  3267. @findex @kbd{Ex t [z]}
  3268. @findex @kbd{Ex move [z]}
  3269. @kindex @kbd{J}
  3270. @kindex @kbd{~}
  3271. @kindex @kbd{=<move>}
  3272. @kindex @kbd{C}
  3273. @kindex @kbd{cc}
  3274. @kindex @kbd{c<move>}
  3275. @kindex @kbd{S}
  3276. @kindex @kbd{s}
  3277. @kindex @kbd{R}
  3278. @kindex @kbd{r<char>}
  3279. @node Search and Replace
  3280. @subsection Search and Replace
  3281. @xref{Groundwork}, for Ex address syntax. @xref{Options}, to see how to
  3282. get literal (non-regular-expression) search and how to stop search from
  3283. wrapping around.
  3284. @table @kbd
  3285. @item C-c /
  3286. Toggle case-sensitive search. With prefix argument, toggle vanilla/regular
  3287. expression search.
  3288. @item <count> /<string>
  3289. To the <count>th occurrence of <string>.
  3290. Viper does not parse search patterns and does not expand special symbols
  3291. found there (e.g., @samp{~} is not expanded to the result of the previous
  3292. substitution).
  3293. After typing @kbd{/} or @kbd{?} all the usual Emacs minibuffer commands, such as
  3294. @kbd{M-p} and @kbd{M-n} are available. In addition, typing @kbd{C-s} will
  3295. insert the last search string used by the Emacs incremental search command
  3296. (which is bound to @kbd{C-s} everywhere except in this case).
  3297. @item <count> ?<string>
  3298. To the <count>th previous occurrence of <string>.
  3299. @item <count> g<move>
  3300. Search for the text described by move. (off by default)
  3301. @item n
  3302. Repeat latest @kbd{/} @kbd{?} (next).
  3303. @item N
  3304. Idem in opposite direction.
  3305. @item %
  3306. Find the next bracket and go to its match
  3307. @item :[x,y]g/<string>/<cmd>
  3308. @cindex text processing
  3309. Search globally [from line x to y] for <string>
  3310. and execute the Ex <cmd> on each occurrence.
  3311. @item :[x,y]v/<string>/<cmd>
  3312. Execute <cmd> on the lines that don't match.
  3313. @item #g<move>
  3314. Execute the last keyboard macro for each line in the region.
  3315. @xref{Macros and Registers}, for more info.
  3316. @item Q
  3317. Query Replace.
  3318. @item :ta <name>
  3319. Search in the tags file where <name> is defined (file, line), and go to it.
  3320. @item :[x,y]s/<pat>/<repl>/<f>
  3321. Substitute (on lines x through y) the pattern <pat> (default the last
  3322. pattern) with <repl>. Useful
  3323. flags <f> are @samp{g} for @samp{global} (i.e., change every
  3324. non-overlapping occurrence of <pat>) and @samp{c} for
  3325. @samp{confirm} (type @samp{y} to confirm a particular
  3326. substitution, else @samp{n}). Instead of @kbd{/} any
  3327. punctuation character other than <space> <tab> and <lf> can be used as
  3328. delimiter.
  3329. Note: @emph{The newline character (inserted as @kbd{C-qC-j})
  3330. can be used in <repl>}.
  3331. @item &
  3332. Repeat latest Ex substitute command, e.g., @kbd{:s/wrong/right}.
  3333. @item :global /<pattern>/<ex-command>
  3334. @itemx :g /<pattern>/<ex-command>
  3335. Execute <ex-command> on all lines that match <pattern>.
  3336. @item :vglobal /<pattern>/<ex-command>
  3337. @itemx :v /<pattern>/<ex-command>
  3338. Execute <ex-command> on all lines that do not match <pattern>.
  3339. @end table
  3340. @kindex @kbd{&}
  3341. @findex @kbd{Ex substitute/<pat>/<repl>/<f>}
  3342. @kindex @kbd{Q}
  3343. @kindex @kbd{#g<move>}
  3344. @findex @kbd{Ex v}
  3345. @findex @kbd{Ex g}
  3346. @findex @kbd{Ex global}
  3347. @findex @kbd{Ex vglobal}
  3348. @findex @kbd{Ex tag <name>}
  3349. @kindex @kbd{%}
  3350. @kindex @kbd{N}
  3351. @kindex @kbd{n}
  3352. @kindex @kbd{g<move>}
  3353. @kindex @kbd{?<string>}
  3354. @kindex @kbd{/<string>}
  3355. @node Yanking
  3356. @subsection Yanking
  3357. @cindex cut and paste
  3358. @cindex paste
  3359. @table @kbd
  3360. @item <count> y<move>
  3361. Yank from begin to endpoint of <count><move>.
  3362. @item <count> "<a-z>y<move>
  3363. Yank from begin to endpoint of <count><move> to register.
  3364. @item <count> "<A-Z>y<move>
  3365. Yank from begin to endpoint of <count><move> and append
  3366. to register.
  3367. @item <count> yy
  3368. <count> lines.
  3369. @item <count> Y
  3370. Idem (should be equivalent to @kbd{y$} though).
  3371. @item m<a-z>
  3372. Mark the cursor position with a letter.
  3373. @item [<a-z>
  3374. Show contents of textmarker.
  3375. @item ]<a-z>
  3376. Show contents of register.
  3377. @item <count> ["<a-z1-9>]p
  3378. Put the contents of the (default undo) buffer
  3379. <count> times after the cursor. The register will
  3380. be automatically down-cased.
  3381. @item <count> ["<a-z1-9>]P
  3382. Put the contents of the (default undo) buffer
  3383. <count> times before the cursor. The register will
  3384. @end table
  3385. @kindex @kbd{P}
  3386. @kindex @kbd{p}
  3387. @kindex @kbd{"<a-z1-9>p}
  3388. @kindex @kbd{"<a-z1-9>P}
  3389. @kindex @kbd{]<a-z>}
  3390. @kindex @kbd{[<a-z>}
  3391. @kindex @kbd{m<a-z>}
  3392. @kindex @kbd{Y}
  3393. @kindex @kbd{yy}
  3394. @kindex @kbd{"<A-Z>y<move>}
  3395. @kindex @kbd{"<a-z>y<move>}
  3396. @kindex @kbd{y<move>}
  3397. @kindex @kbd{yank}
  3398. @findex @kbd{Ex yank}
  3399. @node Undoing
  3400. @subsection Undoing
  3401. @cindex undo
  3402. @cindex backup files
  3403. @table @kbd
  3404. @item u U
  3405. Undo the latest change.
  3406. @item .
  3407. Repeat undo.
  3408. @item :q!
  3409. Quit Vi without writing.
  3410. @item :e!
  3411. Re-edit a messed-up file.
  3412. @item :rec
  3413. Recover file from autosave. Viper also creates backup files
  3414. that have a @samp{~} appended to them.
  3415. @end table
  3416. @findex @kbd{Ex rec}
  3417. @findex @kbd{Ex e!}
  3418. @findex @kbd{Ex q!}
  3419. @kindex @kbd{.}
  3420. @kindex @kbd{U}
  3421. @kindex @kbd{u}
  3422. @node Display
  3423. @section Display
  3424. @cindex scrolling
  3425. @table @kbd
  3426. @item C-g
  3427. At user level 1,
  3428. give file name, status, current line number
  3429. and relative position.@*
  3430. At user levels 2 and higher, abort the current command.
  3431. @item C-c g
  3432. Give file name, status, current line number and relative position---all
  3433. user levels.
  3434. @item C-l
  3435. Refresh the screen.
  3436. @item <count> C-e
  3437. Expose <count> more lines at bottom, cursor stays put (if possible).
  3438. @item <count> C-y
  3439. Expose <count> more lines at top, cursor stays put (if possible).
  3440. @item <count> C-d
  3441. Scroll <count> lines downward (default the number of the previous scroll;
  3442. initialization: half a page).
  3443. @item <count> C-u
  3444. Scroll <count> lines upward (default the number of the previous scroll;
  3445. initialization: half a page).
  3446. @item <count> C-f
  3447. <count> pages forward.
  3448. @item <count> C-b
  3449. <count> pages backward (in older versions @kbd{C-b} only works without count).
  3450. @item <count> z<cr>
  3451. @item zH
  3452. Put line <count> at the top of the window (default the current line).
  3453. @item <count> z-
  3454. @item zL
  3455. Put line <count> at the bottom of the window
  3456. (default the current line).
  3457. @item <count> z.
  3458. @item zM
  3459. Put line <count> in the center of the window
  3460. (default the current line).
  3461. @end table
  3462. @kindex @kbd{zM}
  3463. @kindex @kbd{zL}
  3464. @kindex @kbd{zH}
  3465. @kindex @kbd{z<cr>}
  3466. @kindex @kbd{z.}
  3467. @kindex @kbd{z-}
  3468. @kindex @kbd{z<cr>}
  3469. @kindex @kbd{C-b}
  3470. @kindex @kbd{C-f}
  3471. @kindex @kbd{C-u}
  3472. @kindex @kbd{C-d}
  3473. @kindex @kbd{C-y}
  3474. @kindex @kbd{C-e}
  3475. @kindex @kbd{C-l}
  3476. @kindex @kbd{C-g}
  3477. @node File and Buffer Handling
  3478. @section File and Buffer Handling
  3479. @cindex multiple files
  3480. In all file handling commands, space should be typed before entering the file
  3481. name. If you need to type a modifier, such as @kbd{>>} or @kbd{!}, don't
  3482. put any space between the command and the modifier.
  3483. Note that many Ex commands, e.g., @kbd{:w}, accept command arguments. The
  3484. effect is that the command would start acting on the current region. For
  3485. instance, if the current region spans the lines 11 through 22, then if you
  3486. type @kbd{1:w} you would see @samp{:11,22w} in the minibuffer.
  3487. @table @kbd
  3488. @item :q
  3489. Quit buffer except if modified.
  3490. @item :q!
  3491. Quit buffer without checking. In Viper, these two commands
  3492. are identical. Confirmation is required if exiting modified buffers that
  3493. visit files.
  3494. @item :suspend
  3495. @item :stop
  3496. Suspend Viper
  3497. @item :[x,y] w
  3498. Write the file. Viper makes sure that a final newline is always added to
  3499. any file where this newline is missing. This is done by setting Emacs
  3500. variable @code{require-final-newline} to @code{t}. If you don't like this
  3501. feature, use @code{setq-default} to set @code{require-final-newline} to
  3502. @code{nil}. This must be done in the Viper customization file.
  3503. @item :[x,y] w <name>
  3504. Write to the file <name>.
  3505. @item :[x,y] w>> <name>
  3506. Append the buffer to the file <name>. There should be no space between
  3507. @kbd{w} and @kbd{>>}. Type space after the @kbd{>>} and see what happens.
  3508. @item :w!@: <name>
  3509. Overwrite the file <name>. In Viper, @kbd{:w} and @kbd{:w!} are identical.
  3510. Confirmation is required for writing to an existing file (if this is not
  3511. the file the buffer is visiting) or to a read-only file.
  3512. @item :x,y w <name>
  3513. Write lines x through y to the file <name>.
  3514. @item :wq
  3515. Write the file and kill buffer.
  3516. @item :r <file> [<file> ...]
  3517. Read file into a buffer, inserting its contents after the current line.
  3518. @item :xit
  3519. Same as @kbd{:wq}.
  3520. @item :Write
  3521. @itemx :W
  3522. Save all unsaved buffers, asking for confirmation.
  3523. @item :WWrite
  3524. @itemx :WW
  3525. Like @kbd{W}, but without asking for confirmation.
  3526. @item ZZ
  3527. Save current buffer and kill it. If user level is 1, then save all files
  3528. and kill Emacs. Killing Emacs is the wrong way to use it, so you should
  3529. switch to higher user levels as soon as possible.
  3530. @item :x [<file>]
  3531. Save and kill buffer.
  3532. @item :x!@: [<file>]
  3533. @kbd{:w![<file>]} and @kbd{:q}.
  3534. @item :pre
  3535. Preserve the file---autosave buffers.
  3536. @item :rec
  3537. Recover file from autosave.
  3538. @item :f [<file>]
  3539. without the argument, prints file name and character/line information afout
  3540. the currently visited file. With an argument, sets the currently visited
  3541. filename to @file{file}.
  3542. @item :cd [<dir>]
  3543. Set the working directory to <dir> (default home directory).
  3544. @item :pwd
  3545. Print present working directory.
  3546. @item :e [+<cmd>] <files>
  3547. Edit files. If no filename is given, edit the file visited by the current
  3548. buffer. If buffer was modified or the file changed on disk, ask for
  3549. confirmation. Unlike Vi, Viper allows @kbd{:e} to take multiple arguments.
  3550. The first file is edited the same way as in Vi. The rest are visited
  3551. in the usual Emacs way.
  3552. @item :e!@: [+<cmd>] <files>
  3553. Re-edit file. If no filename, re-edit current file.
  3554. In Viper, unlike Vi, @kbd{e!} is identical to @kbd{:e}. In both cases, the
  3555. user is asked to confirm if there is a danger of discarding changes to a
  3556. buffer.
  3557. @item :q!
  3558. Quit Vi without writing.
  3559. @item C-^
  3560. Edit the alternate (normally the previous) file.
  3561. @item :rew
  3562. Obsolete
  3563. @item :args
  3564. List files not shown anywhere with counts for next
  3565. @item :n [count] [+<cmd>] [<files>]
  3566. Edit <count> file, or edit files. The count comes from @kbd{:args}.
  3567. @item :N [count] [+<cmd>] [<files>]
  3568. Like @kbd{:n}, but the meaning of the variable
  3569. @var{ex-cycle-other-window} is reversed.
  3570. @item :b
  3571. Switch to another buffer. If @var{ex-cycle-other-window} is @code{t},
  3572. switch in another window. Buffer completion is supported.
  3573. The variable @var{viper-read-buffer-function} controls which function is
  3574. actually used to read the buffer name. The default is @code{read-buffer},
  3575. but better alternatives are also available in Emacs (e.g.,
  3576. @code{ido-read-buffer}).
  3577. @vindex @var{viper-read-buffer-function}
  3578. @item :B
  3579. Like @kbd{:b}, but the meaning of @var{ex-cycle-other-window} is reversed.
  3580. @item :<address>r <name>
  3581. Read the file <name> into the buffer after the line <address>.
  3582. @item v, V, C-v
  3583. Edit a file in current or another window, or in another frame. File name
  3584. is typed in minibuffer. File completion and history are supported.
  3585. @end table
  3586. @kindex @kbd{v}
  3587. @kindex @kbd{V}
  3588. @findex @kbd{Ex args}
  3589. @findex @kbd{Ex rew}
  3590. @kindex @kbd{C-^}
  3591. @findex @kbd{Ex e!@: [<files>]}
  3592. @findex @kbd{Ex e [<files>]}
  3593. @findex @kbd{Ex edit [<files>]}
  3594. @findex @kbd{Ex edit!@: [<files>]}
  3595. @findex @kbd{Ex q!}
  3596. @findex @kbd{Ex q}
  3597. @findex @kbd{Ex quit}
  3598. @findex @kbd{Ex quit!}
  3599. @findex @kbd{Ex f}
  3600. @findex @kbd{Ex rec}
  3601. @findex @kbd{Ex r}
  3602. @findex @kbd{Ex read}
  3603. @findex @kbd{Ex pre}
  3604. @kindex @kbd{ZZ}
  3605. @findex @kbd{Ex wq}
  3606. @findex @kbd{Ex w <file>}
  3607. @findex @kbd{Ex w!@: <file>}
  3608. @findex @kbd{Ex w >> <file>}
  3609. @findex @kbd{Ex write <file>}
  3610. @findex @kbd{Ex write!@: <file>}
  3611. @findex @kbd{Ex write >> <file>}
  3612. @findex @kbd{Ex W}
  3613. @findex @kbd{Ex WW}
  3614. @findex @kbd{Ex Write}
  3615. @findex @kbd{Ex WWrite}
  3616. @findex @kbd{Ex WWrite}
  3617. @findex @kbd{Ex x}
  3618. @findex @kbd{Ex x!}
  3619. @findex @kbd{Ex suspend}
  3620. @findex @kbd{Ex stop}
  3621. @findex @kbd{Ex n [<count> | <file>]}
  3622. @findex @kbd{Ex cd [<dir>]}
  3623. @findex @kbd{Ex pwd}
  3624. @node Mapping
  3625. @section Mapping
  3626. @cindex key bindings
  3627. @cindex key mapping
  3628. @table @kbd
  3629. @item :map <string>
  3630. Start defining a Vi-style keyboard macro.
  3631. For instance, typing
  3632. @kbd{:map www} followed by @kbd{:!wc %} and then typing @kbd{C-x )}
  3633. will cause @kbd{www} to run wc on
  3634. current file (Vi replaces @samp{%} with the current file name).
  3635. @item C-x )
  3636. Finish defining a keyboard macro.
  3637. In Viper, this command completes the process of defining all keyboard
  3638. macros, whether they are Emacs-style or Vi-style.
  3639. This is a departure from Vi, needed to allow WYSIWYG mapping of
  3640. keyboard macros and to permit the use of function keys and arbitrary Emacs
  3641. functions in the macros.
  3642. @item :unmap <string>
  3643. Deprive <string> of its mappings in Vi state.
  3644. @item :map!@: <string>
  3645. Map a macro for Insert state.
  3646. @item :unmap!@: <string>
  3647. Deprive <string> of its mapping in Insert state (see @kbd{:unmap}).
  3648. @item @@<a-z>
  3649. In Vi state,
  3650. execute the contents of register as a command.
  3651. @item @@@@
  3652. In Vi state,
  3653. repeat last register command.
  3654. @item @@#
  3655. In Vi state,
  3656. begin keyboard macro. End with @@<a-z>. This will
  3657. put the macro in the proper register. Register will
  3658. be automatically down-cased.
  3659. @xref{Macros and Registers}, for more info.
  3660. @item @@!<a-z>
  3661. In Vi state,
  3662. yank anonymous macro to register
  3663. @item *
  3664. In Vi state,
  3665. execute anonymous macro (defined by C-x( and C-x )).
  3666. @item C-x e
  3667. Like @kbd{*}, but works in all Viper states.
  3668. @item #g<move>
  3669. Execute the last keyboard macro for each line in the region.
  3670. @xref{Macros and Registers}, for more info.
  3671. @item [<a-z>
  3672. Show contents of textmarker.
  3673. @item ]<a-z>
  3674. Show contents of register.
  3675. @end table
  3676. @kindex @kbd{]<a-z>}
  3677. @kindex @kbd{[<a-z>}
  3678. @kindex @kbd{#g<move>}
  3679. @kindex @kbd{*}
  3680. @kindex @kbd{@@!<a-z>}
  3681. @kindex @kbd{@@#}
  3682. @kindex @kbd{@@@@}
  3683. @kindex @kbd{@@<a-z>}
  3684. @findex @kbd{Ex unmap <char>}
  3685. @findex @kbd{Ex map <char> <seq>}
  3686. @findex @kbd{Ex unmap!@: <char>}
  3687. @findex @kbd{Ex map!@: <char> <seq>}
  3688. @node Shell Commands
  3689. @section Shell Commands
  3690. @cindex % (Current file)
  3691. The symbol @samp{%} is used in Ex shell commands to mean current file. If
  3692. you want a @samp{%} in your command, it must be escaped as @samp{\%}.
  3693. @cindex @samp{%} (Ex address)
  3694. However if @samp{%} is the first character, it stands as the address for
  3695. the whole file.
  3696. @cindex @samp{#} (Previous file)
  3697. Similarly, @samp{#} expands to the previous file. The previous file is the
  3698. first file in @kbd{:args} listing. This defaults to the previous file in
  3699. the VI sense if you have one window.
  3700. Symbols @samp{%} and @samp{#} are also used in the Ex commands @kbd{:e} and
  3701. @kbd{:r <shell-cmd>}. The commands @kbd{:w} and the regular @kbd{:r
  3702. <file>} command don't support these meta symbols, because file history is a
  3703. better mechanism.
  3704. @cindex shell commands
  3705. @table @kbd
  3706. @item :sh
  3707. Execute a subshell in another window
  3708. @item :[x,y]!<cmd>
  3709. Execute a shell <cmd> [on lines x through y;
  3710. % is replace by current file, \% is changed to %
  3711. @item :[x,y]!!@: [<args>]
  3712. Repeat last shell command [and append <args>].
  3713. @item :!<cmd>
  3714. Just execute command and display result in a buffer.
  3715. @item :!!@: <args>
  3716. Repeat last shell command and append <args>
  3717. @item <count> !<move><cmd>
  3718. The shell executes <cmd>, with standard
  3719. input the lines described by <count><move>,
  3720. next the standard output replaces those lines
  3721. (think of @samp{cb}, @samp{sort}, @samp{nroff}, etc.).
  3722. @item <count> !!<cmd>
  3723. Give <count> lines as standard input to the
  3724. shell <cmd>, next let the standard output
  3725. replace those lines.
  3726. @item :[x,y] w !<cmd>
  3727. Let lines x to y be standard input for <cmd>
  3728. (notice the <sp> between @kbd{w} and @kbd{!}).
  3729. @item :<address>r !<cmd>
  3730. Put the output of <cmd> after the line <address> (default current).
  3731. @item :<address>r <name>
  3732. Read the file <name> into the buffer after the line <address> (default
  3733. current).
  3734. @item :make
  3735. Run the make command in the current directory.
  3736. @end table
  3737. @findex @kbd{Ex <address>r <name>}
  3738. @findex @kbd{Ex <address>r !<cmd>}
  3739. @findex @kbd{!<cmd>}
  3740. @findex @kbd{!!<cmd>}
  3741. @findex @kbd{!<move><cmd>}
  3742. @findex @kbd{Ex w !<cmd>}
  3743. @findex @kbd{Ex x,y w !<cmd>}
  3744. @findex @kbd{Ex !!@: <args>}
  3745. @findex @kbd{Ex !<cmd>}
  3746. @findex @kbd{Ex sh}
  3747. @findex @kbd{Ex make}
  3748. @node Options
  3749. @section Options
  3750. @cindex Vi options
  3751. @table @kbd
  3752. @item autoindent
  3753. @itemx ai
  3754. @cindex autoindent
  3755. autoindent: In append mode after a <cr> the
  3756. cursor will move directly below the first
  3757. character on the previous line.
  3758. This setting affects the current buffer only.
  3759. @item autoindent-global
  3760. @itemx ai-global
  3761. Same as @code{autoindent}, but affects all buffers.
  3762. @item noautoindent
  3763. @itemx noai
  3764. Cancel autoindent.
  3765. @item noautoindent-global
  3766. @itemx noai-g
  3767. Cancel autoindent-global.
  3768. @item ignorecase
  3769. @itemx ic
  3770. @cindex case and searching
  3771. ignorecase: No distinction between upper and lower cases when searching.
  3772. @item noignorecase
  3773. @itemx noic
  3774. Cancel ignorecase.
  3775. @item magic
  3776. @itemx ma
  3777. @cindex literal searching
  3778. Regular expressions used in searches; nomagic means no regexps.
  3779. @item nomagic
  3780. @item noma
  3781. Cancel magic.
  3782. @item readonly
  3783. @itemx ro
  3784. @cindex readonly files
  3785. readonly: The file is not to be changed.
  3786. If the user attempts to write to this file, confirmation will be requested.
  3787. @item noreadonly
  3788. @itemx noro
  3789. Cancel readonly.
  3790. @item shell=<string>
  3791. @itemx sh=<string>
  3792. @cindex shell
  3793. shell: The program to be used for shell escapes
  3794. (default @samp{$SHELL} (default @file{/bin/sh})).
  3795. @item shiftwidth=<count>
  3796. @itemx sw=<count>
  3797. @cindex layout
  3798. @cindex shifting text
  3799. shiftwidth: Gives the shiftwidth (default 8 positions).
  3800. @item showmatch
  3801. @itemx sm
  3802. @cindex paren matching
  3803. @cindex matching parens
  3804. showmatch: Whenever you append a @kbd{)}, Vi shows
  3805. its match if it's on the same page; also with
  3806. @kbd{@{} and @kbd{@}}. If there's no match, Vi will beep.
  3807. @item noshowmatch
  3808. @itemx nosm
  3809. Cancel showmatch.
  3810. @item tabstop=<count>
  3811. @itemx ts=<count>
  3812. @cindex changing tab width
  3813. @cindex tabbing
  3814. tabstop: The length of a <ht>; warning: this is
  3815. only IN the editor, outside of it <ht>s have
  3816. their normal length (default 8 positions).
  3817. This setting affects the current buffer only.
  3818. @item tabstop-global
  3819. @itemx ts-g
  3820. Same as @code{tabstop}, but affects all buffers.
  3821. @item wrapmargin=<count>
  3822. @itemx wm=<count>
  3823. @cindex auto fill
  3824. @cindex word wrap
  3825. wrapmargin: In append mode Vi automatically
  3826. puts a <lf> whenever there is a <sp> or <ht>
  3827. within <wm> columns from the right margin.
  3828. @item wrapscan
  3829. @itemx ws
  3830. @cindex searching
  3831. wrapscan: When searching, the end is
  3832. considered @samp{stuck} to the begin of the file.
  3833. @item nowrapscan
  3834. @itemx nows
  3835. Cancel wrapscan.
  3836. @item :set <option>
  3837. Turn <option> on.
  3838. @item :set no<option>
  3839. Turn <option> off.
  3840. @item :set <option>=<value>
  3841. Set <option> to <value>.
  3842. @end table
  3843. @findex @kbd{Ex set <option>=<value>}
  3844. @findex @kbd{Ex set no<option>}
  3845. @findex @kbd{Ex set <option>}
  3846. @findex @kbd{Ex set ws}
  3847. @findex @kbd{Ex set wrapscan}
  3848. @findex @kbd{Ex set wm=<count>}
  3849. @findex @kbd{Ex set wrapmargin=<count>}
  3850. @findex @kbd{Ex set ts=<count>}
  3851. @findex @kbd{Ex set tabstop=<count>}
  3852. @findex @kbd{Ex set tab-stop-local=<count>}
  3853. @findex @kbd{Ex set sm}
  3854. @findex @kbd{Ex set showmatch}
  3855. @findex @kbd{Ex set sw=<count>}
  3856. @findex @kbd{Ex set shiftwidth=<count>}
  3857. @findex @kbd{Ex set sh=<string>}
  3858. @findex @kbd{Ex set shell=<string>}
  3859. @findex @kbd{Ex set ro}
  3860. @findex @kbd{Ex set readonly}
  3861. @findex @kbd{Ex set magic}
  3862. @findex @kbd{Ex set ic}
  3863. @findex @kbd{Ex set ignorecase}
  3864. @findex @kbd{Ex set ai}
  3865. @findex @kbd{Ex set autoindent}
  3866. @node Emacs Related Commands
  3867. @section Emacs Related Commands
  3868. @table @kbd
  3869. @item C-\
  3870. Begin Meta command in Vi or Insert states. Most often used as C-\ x (M-x).
  3871. Note: Emacs binds @kbd{C-\} to a function that offers to change the
  3872. keyboard input method in the multilingual environment. Viper overrides this
  3873. binding. However, it is still possible to switch the input method by typing
  3874. @kbd{\ C-\} in the Vi command state and @kbd{C-z \ C-\} in the Insert state.
  3875. Or you can use the MULE menu on the menubar.
  3876. @item C-z
  3877. In Insert and Replace states, prepare Viper to accept the next command and
  3878. execute it as if Viper was in Vi state. Then return to Insert state.
  3879. In Vi state, switch to Emacs state; in Emacs state, switch to Vi state.
  3880. @item C-c \
  3881. Switches to Vi state for the duration of a single command. Then goes back
  3882. to the original Viper state. Works from Vi, Insert, Replace, and Emacs states.
  3883. @item C-x0
  3884. Close Window
  3885. @item C-x1
  3886. Close Other Windows
  3887. @item C-x2
  3888. Split Window
  3889. @item C-xo
  3890. Move among windows
  3891. @item C-xC-f
  3892. Emacs find-file, useful in Insert state
  3893. @item C-y
  3894. Put back the last killed text. Similar to Vi's @kbd{p}, but also works in
  3895. Insert and Replace state. This command doesn't work in Vi command state,
  3896. since this binding is taken for something else.
  3897. @item M-y
  3898. Undoes the last @kbd{C-y} and puts another kill from the kill ring.
  3899. Using this command, you can try may different kills until you find the one
  3900. you need.
  3901. @end table
  3902. @kindex @kbd{M-y}
  3903. @kindex @kbd{C-y}
  3904. @kindex @kbd{C-xC-f}
  3905. @kindex @kbd{C-xo}
  3906. @kindex @kbd{C-x2}
  3907. @kindex @kbd{C-x1}
  3908. @kindex @kbd{C-x0}
  3909. @kindex @kbd{C-z}
  3910. @kindex @kbd{C-\}
  3911. @kindex @kbd{C-c\}
  3912. @node Mouse-bound Commands
  3913. @section Mouse-bound Commands
  3914. The following two mouse actions are normally bound to special search and
  3915. insert commands in of Viper:
  3916. @table @kbd
  3917. @item S-Mouse-1
  3918. Holding Shift and clicking mouse button 1 will
  3919. initiate search for
  3920. a region under the mouse pointer.
  3921. This command can take a prefix argument. Note: Viper sets this
  3922. binding only if this mouse action is not
  3923. already bound to something else.
  3924. @xref{Viper Specials}, for more information.
  3925. @item S-Mouse-2
  3926. Holding Shift and clicking button 2 of the mouse will
  3927. insert a region surrounding the mouse pointer.
  3928. This command can also take a prefix argument.
  3929. Note: Viper sets this binding only if this mouse action is not
  3930. already bound to something else.
  3931. @xref{Viper Specials}, for more details.
  3932. @end table
  3933. @kindex @kbd{S-Mouse-1}
  3934. @kindex @kbd{S-Mouse-2}
  3935. @kindex @kbd{meta button1up}
  3936. @kindex @kbd{meta button2up}
  3937. @node GNU Free Documentation License
  3938. @appendix GNU Free Documentation License
  3939. @include doclicense.texi
  3940. @node Acknowledgments
  3941. @unnumbered Acknowledgments
  3942. Viper, formerly known as VIP-19, was written by Michael Kifer. Viper is
  3943. based on the original VIP package by Masahiko Sato and on its enhancement,
  3944. VIP 4.4, by Aamod Sane. This manual is an adaptation of the manual for VIP
  3945. 4.4, which, in turn, was based on Sato's manual for VIP 3.5.
  3946. Many contributors on the Net pointed out bugs and suggested a number of
  3947. useful features. Scott Bronson and Samuel Padgett contributed patches that
  3948. were incorporated in this code. Here is a hopefully complete list of
  3949. contributors:
  3950. @example
  3951. aaronl@@vitelus.com (Aaron Lehmann),
  3952. ahg@@panix.com (Al Gelders),
  3953. amade@@diagram.fr (Paul-Bernard Amade),
  3954. ascott@@fws214.intel.com (Andy Scott),
  3955. bronson@@trestle.com (Scott Bronson),
  3956. cook@@biostat.wisc.edu (Tom Cook),
  3957. csdayton@@midway.uchicago.edu (Soren Dayton),
  3958. dave@@hellgate.utah.edu,
  3959. dm@@scs.cs.nyu.edu (David Mazieres),
  3960. dominik@@strw.LeidenUniv.nl (Carsten Dominik),
  3961. dwallach@@cs.princeton.edu (Dan Wallach),
  3962. dwight@@toolucky.llnl.gov (Dwight Shih),
  3963. dxc@@xprt.net (David X Callaway),
  3964. edmonds@@edmonds.home.cs.ubc.ca (Brian Edmonds),
  3965. gin@@mo.msk.ru (Golubev I.N.),
  3966. gviswana@@cs.wisc.edu (Guhan Viswanathan),
  3967. gvr@@halcyon.com (George V. Reilly),
  3968. hatazaki@@bach.convex.com (Takao Hatazaki),
  3969. hpz@@ibmhpz.aug.ipp-garching.mpg.de (Hans-Peter Zehrfeld),
  3970. irie@@t.email.ne.jp (Irie Tetsuya),
  3971. jackr@@dblues.engr.sgi.com (Jack Repenning),
  3972. jamesm@@bga.com (D.J. Miller II),
  3973. jjm@@hplb.hpl.hp.com (Jean-Jacques Moreau),
  3974. jl@@cse.ogi.edu (John Launchbury),
  3975. jobrien@@hchp.org (John O'Brien),
  3976. johnw@@borland.com (John Wiegley),
  3977. kanze@@gabi-soft.fr (James Kanze),
  3978. kin@@isi.com (Kin Cho),
  3979. kwzh@@gnu.org (Karl Heuer),
  3980. lindstro@@biostat.wisc.edu (Mary Lindstrom),
  3981. lektu@@terra.es (Juanma Barranquero),
  3982. lennart.borgman.073@@student.lu.se (Lennart Borgman),
  3983. minakaji@@osaka.email.ne.jp (Mikio Nakajima),
  3984. Mark.Bordas@@East.Sun.COM (Mark Bordas),
  3985. meyering@@comco.com (Jim Meyering),
  3986. martin@@xemacs.org (Martin Buchholz),
  3987. mbutler@@redfernnetworks.com (Malcolm Butler),
  3988. mveiga@@dit.upm.es (Marcelino Veiga Tuimil),
  3989. paulk@@summit.esg.apertus.com (Paul Keusemann),
  3990. pfister@@cs.stonybrook.edu (Hanspeter Pfister),
  3991. phil_brooks@@MENTORG.COM (Phil Brooks),
  3992. pogrell@@informatik.hu-berlin.de (Lutz Pogrell),
  3993. pradyut@@cs.uchicago.edu (Pradyut Shah),
  3994. roderick@@argon.org (Roderick Schertler),
  3995. rxga@@ulysses.att.com,
  3996. sawdey@@lcse.umn.edu (Aaron Sawdey),
  3997. simonb@@prl.philips.co.uk (Simon Blanchard),
  3998. spadgett1@@nc.rr.com (Samuel Padgett),
  3999. stephen@@farrell.org (Stephen Farrell),
  4000. storm@@cua.dk (Kim F. Storm),
  4001. sudish@@MindSpring.COM (Sudish Joseph),
  4002. schwab@@issan.informatik.uni-dortmund.de (Andreas Schwab)
  4003. terra@@diku.dk (Morten Welinder),
  4004. thanh@@informatics.muni.cz (Han The Thanh),
  4005. toma@@convex.convex.com,
  4006. vrenjak@@sun1.racal.com (Milan Vrenjak),
  4007. whicken@@dragon.parasoft.com (Wendell Hicken),
  4008. zapman@@cc.gatech.edu (Jason Zapman II),
  4009. @end example
  4010. @node Key Index
  4011. @unnumbered Key Index
  4012. @printindex ky
  4013. @node Function Index
  4014. @unnumbered Function Index
  4015. @printindex fn
  4016. @node Variable Index
  4017. @unnumbered Variable Index
  4018. @printindex vr
  4019. @node Package Index
  4020. @unnumbered Package Index
  4021. @printindex pg
  4022. @node Concept Index
  4023. @unnumbered Concept Index
  4024. @printindex cp
  4025. @bye