vip.texi 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953
  1. \input texinfo
  2. @setfilename ../../info/vip.info
  3. @settitle VIP
  4. @include docstyle.texi
  5. @copying
  6. Copyright @copyright{} 1987, 2001--2016 Free Software Foundation, Inc.
  7. @quotation
  8. Permission is granted to copy, distribute and/or modify this document
  9. under the terms of the GNU Free Documentation License, Version 1.3 or
  10. any later version published by the Free Software Foundation; with no
  11. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
  12. and with the Back-Cover Texts as in (a) below. A copy of the license
  13. is included in the section entitled ``GNU Free Documentation License''.
  14. (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
  15. modify this GNU manual.''
  16. @end quotation
  17. @end copying
  18. @titlepage
  19. @sp 10
  20. @center @titlefont{VIP}
  21. @sp 1
  22. @center A Vi Package for GNU Emacs
  23. @center (Version 3.5, September 15, 1987)
  24. @sp 2
  25. @center Masahiko Sato
  26. @page
  27. @vskip 0pt plus1filll
  28. @insertcopying
  29. @end titlepage
  30. @finalout
  31. @contents
  32. @dircategory Emacs misc features
  33. @direntry
  34. * VIP: (vip). An obsolete VI-emulation for Emacs.
  35. @end direntry
  36. @ifnottex
  37. @node Top
  38. @top VIP
  39. VIP is a Vi emulating package written in Emacs Lisp. VIP implements most
  40. Vi commands including Ex commands. It is therefore hoped that this package
  41. will enable you to do Vi style editing under the powerful GNU Emacs
  42. environment. This info file describes the usage of VIP assuming that you
  43. are fairly accustomed to Vi but not so much with Emacs. Also we will
  44. concentrate mainly on differences from Vi, especially features unique to
  45. VIP.
  46. VIP is obsolete since Emacs 24.5---consider using Viper instead.
  47. @xref{Top, Viper,, viper, The Viper VI-emulation mode for Emacs}.
  48. It is recommended that you read nodes on survey and on customization before
  49. you start using VIP@. Other nodes may be visited as needed.
  50. Comments and bug reports are welcome. Please send messages to
  51. @code{ms@@Sail.Stanford.Edu} if you are outside of Japan and to
  52. @code{masahiko@@sato.riec.tohoku.junet} if you are in Japan.
  53. @insertcopying
  54. @end ifnottex
  55. @menu
  56. * Survey:: A survey of VIP.
  57. * Vi Commands:: Details of Vi commands.
  58. * Ex Commands:: Details of Ex commands.
  59. * Customization:: How to customize VIP.
  60. * GNU Free Documentation License:: The license for this documentation.
  61. @end menu
  62. @iftex
  63. @unnumbered Introduction
  64. VIP is a Vi emulating package written in Emacs Lisp. VIP implements most
  65. Vi commands including Ex commands. It is therefore hoped that this package
  66. will enable you to do Vi style editing under the powerful GNU Emacs
  67. environment. This manual describes the usage of VIP assuming that you are
  68. fairly accustomed to Vi but not so much with Emacs. Also we will
  69. concentrate mainly on differences from Vi, especially features unique to
  70. VIP.
  71. VIP is obsolete since Emacs 24.5---consider using Viper instead.
  72. @xref{Top, Viper,, viper, The Viper VI-emulation mode for Emacs}.
  73. It is recommended that you read chapters on survey and on customization
  74. before you start using VIP@. Other chapters may be used as future
  75. references.
  76. Comments and bug reports are welcome. Please send messages to
  77. @code{ms@@Sail.Stanford.Edu} if you are outside of Japan and to
  78. @code{masahiko@@unsun.riec.tohoku.junet} if you are in Japan.
  79. @end iftex
  80. @node Survey
  81. @chapter A Survey of VIP
  82. In this chapter we describe basics of VIP with emphasis on the features not
  83. found in Vi and on how to use VIP under GNU Emacs.
  84. @menu
  85. * Basic Concepts:: Basic concepts in Emacs.
  86. * Loading VIP:: How to load VIP automatically.
  87. * Modes in VIP:: VIP has three modes, which are orthogonal to modes
  88. in Emacs.
  89. * Differences from Vi:: Differences of VIP from Vi is explained.
  90. @end menu
  91. @node Basic Concepts
  92. @section Basic Concepts
  93. We begin by explaining some basic concepts of Emacs. These concepts are
  94. explained in more detail in the GNU Emacs Manual.
  95. @cindex buffer
  96. @cindex point
  97. @cindex mark
  98. @cindex text
  99. @cindex looking at
  100. @cindex end (of buffer)
  101. @cindex region
  102. Conceptually, a @dfn{buffer} is just a string of @acronym{ASCII} characters and two
  103. special characters @key{PNT} (@dfn{point}) and @key{MRK} (@dfn{mark}) such
  104. that the character @key{PNT} occurs exactly once and @key{MRK} occurs at
  105. most once. The @dfn{text} of a buffer is obtained by deleting the
  106. occurrences of @key{PNT} and @key{MRK}. If, in a buffer, there is a
  107. character following @key{PNT} then we say that point is @dfn{looking at}
  108. the character; otherwise we say that point is @dfn{at the end of buffer}.
  109. @key{PNT} and @key{MRK} are used
  110. to indicate positions in a buffer and they are not part of the text of the
  111. buffer. If a buffer contains a @key{MRK} then the text between @key{MRK}
  112. and @key{PNT} is called the @dfn{region} of the buffer.
  113. @cindex window
  114. Emacs provides (multiple) @dfn{windows} on the screen, and you can see the
  115. content of a buffer through the window associated with the buffer. The
  116. cursor of the screen is always positioned on the character after @key{PNT}.
  117. @cindex mode
  118. @cindex keymap
  119. @cindex local keymap
  120. @cindex global keymap
  121. A @dfn{keymap} is a table that records the bindings between characters and
  122. command functions. There is the @dfn{global keymap} common to all the
  123. buffers. Each buffer has its @dfn{local keymap} that determines the
  124. @dfn{mode} of the buffer. Local keymap overrides global keymap, so that if
  125. a function is bound to some key in the local keymap then that function will
  126. be executed when you type the key. If no function is bound to a key in the
  127. local map, however, the function bound to the key in the global map becomes
  128. in effect.
  129. @node Loading VIP
  130. @section Loading VIP
  131. The recommended way to load VIP automatically is to include the line:
  132. @example
  133. (load "vip")
  134. @end example
  135. @noindent
  136. in your @file{.emacs} file. The @file{.emacs} file is placed in your home
  137. directory and it will be executed every time you invoke Emacs. If you wish
  138. to be in vi mode whenever Emacs starts up, you can include the following
  139. line in your @file{.emacs} file instead of the above line:
  140. @example
  141. (add-hook 'emacs-startup-hook 'vip-mode)
  142. @end example
  143. @noindent
  144. (@xref{Vi Mode}, for the explanation of vi mode.)
  145. Even if your @file{.emacs} file does not contain any of the above lines,
  146. you can load VIP and enter vi mode by typing the following from within
  147. Emacs.
  148. @example
  149. M-x vip-mode
  150. @end example
  151. @noindent
  152. @node Modes in VIP
  153. @section Modes in VIP
  154. @kindex 032 @kbd{C-z} (@code{vip-change-mode-to-vi})
  155. @kindex 0301 @kbd{C-x C-z} (@code{suspend-emacs})
  156. Loading VIP has the effect of globally binding @kbd{C-z} (@kbd{Control-z})
  157. to the function @code{vip-change-mode-to-vi}. The default binding of @kbd{C-z}
  158. in GNU Emacs is @code{suspend-emacs}, but, you can also call
  159. @code{suspend-emacs} by typing @kbd{C-x C-z}. Other than this, all the
  160. key bindings of Emacs remain the same after loading VIP.
  161. @cindex vi mode
  162. Now, if you hit @kbd{C-z}, the function @code{vip-change-mode-to-vi} will be
  163. called and you will be in @dfn{vi mode}. (Some major modes may locally bind
  164. @kbd{C-z} to some special functions. In such cases, you can call
  165. @code{vip-change-mode-to-vi} by @code{execute-extended-command} which is
  166. invoked by @kbd{M-x}. Here @kbd{M-x} means @kbd{Meta-x}, and if your
  167. terminal does not have a @key{META} key you can enter it by typing
  168. @kbd{@key{ESC} x}. The same effect can also be achieve by typing
  169. @kbd{M-x vip-mode}.)
  170. @cindex mode line
  171. You can observe the change of mode by looking at the @dfn{mode line}. For
  172. instance, if the mode line is:
  173. @example
  174. -----Emacs: *scratch* (Lisp Interaction)----All------------
  175. @end example
  176. @noindent
  177. then it will change to:
  178. @example
  179. -----Vi: *scratch* (Lisp Interaction)----All------------
  180. @end example
  181. @noindent
  182. Thus the word @samp{Emacs} in the mode line will change to @samp{Vi}.
  183. @cindex insert mode
  184. @cindex emacs mode
  185. You can go back to the original @dfn{emacs mode} by typing @kbd{C-z} in
  186. vi mode. Thus @kbd{C-z} toggles between these two modes.
  187. Note that modes in VIP exist orthogonally to modes in Emacs. This means
  188. that you can be in vi mode and at the same time, say, shell mode.
  189. Vi mode corresponds to Vi's command mode. From vi mode you can enter
  190. @dfn{insert mode} (which corresponds to Vi's insert mode) by usual Vi command
  191. keys like @kbd{i}, @kbd{a}, @kbd{o} @dots{} etc.
  192. In insert mode, the mode line will look like this:
  193. @example
  194. -----Insert *scratch* (Lisp Interaction)----All------------
  195. @end example
  196. @noindent
  197. You can exit from insert mode by hitting @key{ESC} key as you do in Vi.
  198. That VIP has three modes may seem very complicated, but in fact it is not
  199. so. VIP is implemented so that you can do most editing remaining only
  200. in the two modes for Vi (that is vi mode and insert mode).
  201. @ifinfo
  202. The figure below shows the transition of three modes in VIP.
  203. @display
  204. === C-z ==> == i,o ... ==>
  205. emacs mode vi mode insert mode
  206. <== X-z === <=== ESC ====
  207. @end display
  208. @end ifinfo
  209. @menu
  210. * Emacs Mode:: This is the mode you should know better.
  211. * Vi Mode:: Vi commands are executed in this mode.
  212. * Insert Mode:: You can enter text, and also can do editing if you
  213. know enough Emacs commands.
  214. @end menu
  215. @node Emacs Mode
  216. @subsection Emacs Mode
  217. @kindex 032 @kbd{C-z} (@code{vip-change-mode-to-vi})
  218. You will be in this mode just after you loaded VIP@. You can do all
  219. normal Emacs editing in this mode. Note that the key @kbd{C-z} is globally
  220. bound to @code{vip-change-mode-to-vi}. So, if you type @kbd{C-z} in this mode
  221. then you will be in vi mode.
  222. @node Vi Mode
  223. @subsection Vi Mode
  224. This mode corresponds to Vi's command mode. Most Vi commands work as they
  225. do in Vi. You can go back to emacs mode by typing @kbd{C-z}. You can
  226. enter insert mode, just as in Vi, by typing @kbd{i}, @kbd{a} etc.
  227. @node Insert Mode
  228. @subsection Insert Mode
  229. The key bindings in this mode is the same as in the emacs mode except for
  230. the following 4 keys. So, you can move around in the buffer and change
  231. its content while you are in insert mode.
  232. @table @kbd
  233. @item @key{ESC}
  234. @kindex 033 @kbd{ESC} (@code{vip-change-mode-to-vi}) (insert mode)
  235. This key will take you back to vi mode.
  236. @item C-h
  237. @kindex 010 @kbd{C-h} (@code{vip-delete-backward-char}) (insert mode)
  238. Delete previous character.
  239. @item C-w
  240. @kindex 027 @kbd{C-w} (@code{vip-delete-backward-word}) (insert mode)
  241. Delete previous word.
  242. @item C-z
  243. @kindex 032 @kbd{C-z} (@code{vip-ESC}) (insert mode)
  244. Typing this key has the same effect as typing @key{ESC} in emacs mode.
  245. Thus typing @kbd{C-z x} in insert mode will have the same effect as typing
  246. @kbd{ESC x} in emacs mode.
  247. @end table
  248. @node Differences from Vi
  249. @section Differences from Vi
  250. The major differences from Vi are explained below.
  251. @menu
  252. * Undoing:: You can undo more in VIP.
  253. * Changing:: Commands for changing the text.
  254. * Searching:: Search commands.
  255. * z Command:: You can now use zH, zM and zL as well as z- etc.
  256. * Counts:: Some Vi commands which do not accept a count now
  257. accept one.
  258. * Marking:: You can now mark the current point, beginning of
  259. the buffer etc.
  260. * Region Commands:: You can now give a region as an argument for delete
  261. commands etc.
  262. * New Commands:: Some new commands not available in Vi are added.
  263. * New Bindings:: Bindings of some keys are changed for the
  264. convenience of editing under Emacs.
  265. * Window Commands:: Commands for moving among windows etc.
  266. * Buffer Commands:: Commands for selecting buffers etc.
  267. * File Commands:: Commands for visiting files etc.
  268. * Misc Commands:: Other useful commands.
  269. @end menu
  270. @node Undoing
  271. @subsection Undoing
  272. @kindex 165 @kbd{u} (@code{vip-undo})
  273. @kindex 056 @kbd{.} (@code{vip-repeat})
  274. You can repeat undoing by the @kbd{.} key. So, @kbd{u} will undo
  275. a single change, while @kbd{u .@: .@: .@:}, for instance, will undo 4 previous
  276. changes. Undo is undoable as in Vi. So the content of the buffer will
  277. be the same before and after @kbd{u u}.
  278. @node Changing
  279. @subsection Changing
  280. Some commands which change a small number of characters are executed
  281. slightly differently. Thus, if point is at the beginning of a word
  282. @samp{foo} and you wished to change it to @samp{bar} by typing @w{@kbd{c w}},
  283. then VIP will prompt you for a new word in the minibuffer by the prompt
  284. @samp{foo => }. You can then enter @samp{bar} followed by @key{RET} or
  285. @key{ESC} to complete the command. Before you enter @key{RET} or
  286. @key{ESC} you can abort the command by typing @kbd{C-g}. In general,
  287. @kindex 007 @kbd{C-g} (@code{vip-keyboard-quit})
  288. you can abort a partially formed command by typing @kbd{C-g}.
  289. @node Searching
  290. @subsection Searching
  291. @kindex 057 @kbd{/} (@code{vip-search-forward})
  292. @kindex 077 @kbd{?} (@code{vip-search-backward})
  293. As in Vi, searching is done by @kbd{/} and @kbd{?}. The string will be
  294. searched literally by default. To invoke a regular expression search,
  295. first execute the search command @kbd{/} (or @kbd{?}) with empty search
  296. string. (I.e., type @kbd{/} followed by @key{RET}.)
  297. A search for empty string will toggle the search mode between vanilla
  298. search and regular expression search. You cannot give an offset to the
  299. search string. (It is a limitation.) By default, search will wrap around
  300. the buffer as in Vi. You can change this by rebinding the variable
  301. @code{vip-search-wrap-around}. @xref{Customization}, for how to do this.
  302. @node z Command
  303. @subsection z Command
  304. @kindex 1723 @kbd{z H} (@code{vip-line-to-top})
  305. @kindex 1721 @kbd{z RET} (@code{vip-line-to-top})
  306. @kindex 1723 @kbd{z M} (@code{vip-line-to-middle})
  307. @kindex 1722 @kbd{z .} (@code{vip-line-to-middle})
  308. @kindex 1723 @kbd{z L} (@code{vip-line-to-bottom})
  309. @kindex 1722 @kbd{z -} (@code{vip-line-to-bottom})
  310. For those of you who cannot remember which of @kbd{z} followed by @key{RET},
  311. @kbd{.}@: and @kbd{-} do what. You can also use @kbd{z} followed by @kbd{H},
  312. @kbd{M} and @kbd{L} to place the current line in the Home (Middle, and
  313. Last) line of the window.
  314. @node Counts
  315. @subsection Counts
  316. Some Vi commands which do not accept a count now accept one
  317. @table @kbd
  318. @item p
  319. @itemx P
  320. @kindex 160 @kbd{p} (@code{vip-put-back})
  321. @kindex 120 @kbd{P} (@code{vip-Put-back})
  322. Given counts, text will be yanked (in Vi's sense) that many times. Thus
  323. @kbd{3 p} is the same as @kbd{p p p}.
  324. @item o
  325. @itemx O
  326. @kindex 157 @kbd{o} (@code{vip-open-line})
  327. @kindex 117 @kbd{O} (@code{vip-Open-line})
  328. Given counts, that many copies of text will be inserted. Thus
  329. @kbd{o a b c @key{ESC}} will insert 3 lines of @samp{abc} below the current
  330. line.
  331. @item /
  332. @itemx ?
  333. @kindex 057 @kbd{/} (@code{vip-search-forward})
  334. @kindex 077 @kbd{?} (@code{vip-search-backward})
  335. Given a count @var{n}, @var{n}-th occurrence will be searched.
  336. @end table
  337. @node Marking
  338. @subsection Marking
  339. Typing an @kbd{m} followed by a lower-case character @var{ch} marks the
  340. point to the register named @var{ch} as in Vi. In addition to these, we
  341. have following key bindings for marking.
  342. @kindex 155 @kbd{m} (@code{vip-mark-point})
  343. @table @kbd
  344. @item m <
  345. Set mark at the beginning of buffer.
  346. @item m >
  347. Set mark at the end of buffer.
  348. @item m .
  349. Set mark at point (and push old mark on mark ring).
  350. @item m ,
  351. Jump to mark (and pop mark off the mark ring).
  352. @end table
  353. @node Region Commands
  354. @subsection Region Commands
  355. @cindex region
  356. Vi operators like @kbd{d}, @kbd{c} etc.@: are usually used in combination
  357. with motion commands. It is now possible to use current region as the
  358. argument to these operators. (A @dfn{region} is a part of buffer
  359. delimited by point and mark.) The key @kbd{r} is used for this purpose.
  360. Thus @kbd{d r} will delete the current region. If @kbd{R} is used instead
  361. of @kbd{r} the region will first be enlarged so that it will become the
  362. smallest region containing the original region and consisting of whole
  363. lines. Thus @kbd{m .@: d R} will have the same effect as @kbd{d d}.
  364. @node New Commands
  365. @subsection Some New Commands
  366. Note that the keys below (except for @kbd{R}) are not used in Vi.
  367. @table @kbd
  368. @item C-a
  369. @kindex 001 @kbd{C-a} (@code{vip-beginning-of-line})
  370. Move point to the beginning of line.
  371. @item C-n
  372. @kindex 016 @kbd{C-n} (@code{vip-next-window})
  373. If you have two or more windows in the screen, this key will move point to
  374. the next window.
  375. @item C-o
  376. @kindex 017 @kbd{C-o} (@code{vip-open-line-at-point})
  377. Insert a newline and leave point before it, and then enter insert mode.
  378. @item C-r
  379. @kindex 022 @kbd{C-r} (@code{isearch-backward})
  380. Backward incremental search.
  381. @item C-s
  382. @kindex 023 @kbd{C-s} (@code{isearch-forward})
  383. Forward incremental search.
  384. @item C-c
  385. @itemx C-x
  386. @itemx @key{ESC}
  387. @kindex 003 @kbd{C-c} (@code{vip-ctl-c})
  388. @kindex 0300 @kbd{C-x} (@code{vip-ctl-x})
  389. @kindex 033 @kbd{ESC} (@code{vip-ESC})
  390. These keys will exit from vi mode and return to emacs mode temporarily. If
  391. you hit one of these keys, Emacs will be in emacs mode and will believe
  392. that you hit that key in emacs mode. For example, if you hit @kbd{C-x}
  393. followed by @kbd{2}, then the current window will be split into 2 and you
  394. will be in vi mode again.
  395. @item \
  396. @kindex 134 @kbd{\} (@code{vip-escape-to-emacs})
  397. Escape to emacs mode. Hitting @kbd{\} will take you to emacs mode, and you
  398. can execute a single Emacs command. After executing the Emacs command you
  399. will be in vi mode again. You can give a count before typing @kbd{\}.
  400. Thus @kbd{5 \ *}, as well as @kbd{\ C-u 5 *}, will insert @samp{*****}
  401. before point. Similarly @kbd{1 0 \ C-p} will move the point 10 lines above
  402. the current line.
  403. @item K
  404. @kindex 113 @kbd{K} (@code{vip-kill-buffer})
  405. Kill current buffer if it is not modified. Useful when you selected a
  406. buffer which you did not want.
  407. @item Q
  408. @itemx R
  409. @kindex 121 @kbd{Q} (@code{vip-query-replace})
  410. @kindex 122 @kbd{R} (@code{vip-replace-string})
  411. @kbd{Q} is for query replace and @kbd{R} is for replace. By default,
  412. string to be replaced are treated literally. If you wish to do a regular
  413. expression replace, first do replace with empty string as the string to be
  414. replaced. In this way, you can toggle between vanilla and regular
  415. expression replacement.
  416. @item v
  417. @itemx V
  418. @kindex 166 @kbd{v} (@code{vip-find-file})
  419. @kindex 126 @kbd{V} (@code{vip-find-file-other-window})
  420. These keys are used to Visit files. @kbd{v} will switch to a buffer
  421. visiting file whose name can be entered in the minibuffer. @kbd{V} is
  422. similar, but will use window different from the current window.
  423. @item #
  424. @kindex 0430 @kbd{#} (@code{vip-command-argument})
  425. If followed by a certain character @var{ch}, it becomes an operator whose
  426. argument is the region determined by the motion command that follows.
  427. Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q} and
  428. @kbd{s}.
  429. @item # c
  430. @kindex 0432 @kbd{# c} (@code{downcase-region})
  431. Change upper-case characters in the region to lower case
  432. (@code{downcase-region}).
  433. @item # C
  434. @kindex 0431 @kbd{# C} (@code{upcase-region})
  435. Change lower-case characters in the region to upper case. For instance,
  436. @kbd{# C 3 w} will capitalize 3 words from the current point
  437. (@code{upcase-region}).
  438. @item # g
  439. @kindex 0432 @kbd{# g} (@code{vip-global-execute})
  440. Execute last keyboard macro for each line in the region
  441. (@code{vip-global-execute}).
  442. @item # q
  443. @kindex 0432 @kbd{# q} (@code{vip-quote-region})
  444. Insert specified string at the beginning of each line in the region
  445. (@code{vip-quote-region}).
  446. @item # s
  447. @kindex 0432 @kbd{# s} (@code{spell-region})
  448. Check spelling of words in the region (@code{spell-region}).
  449. @item *
  450. @kindex 052 @kbd{*} (@code{vip-call-last-kbd-macro})
  451. Call last keyboard macro.
  452. @end table
  453. @node New Bindings
  454. @subsection New Key Bindings
  455. In VIP the meanings of some keys are entirely different from Vi. These key
  456. bindings are done deliberately in the hope that editing under Emacs will
  457. become easier. It is however possible to rebind these keys to functions
  458. which behave similarly as in Vi. @xref{Customizing Key Bindings}, for
  459. details.
  460. @table @kbd
  461. @item C-g
  462. @itemx g
  463. @kindex 007 @kbd{C-g} (@code{vip-keyboard-quit})
  464. @kindex 147 @kbd{g} (@code{vip-info-on-file})
  465. In Vi, @kbd{C-g} is used to get information about the file associated to
  466. the current buffer. Here, @kbd{g} will do that, and @kbd{C-g} is
  467. used to abort a command (this is for compatibility with emacs mode.)
  468. @item SPC
  469. @itemx @key{RET}
  470. @kindex 040 @kbd{SPC} (@code{vip-scroll})
  471. @kindex 015 @kbd{RET} (@code{vip-scroll-back})
  472. Now these keys will scroll up and down the text of current window.
  473. Convenient for viewing the text.
  474. @item s
  475. @itemx S
  476. @kindex 163 @kbd{s} (@code{vip-switch-to-buffer})
  477. @kindex 123 @kbd{S} (@code{vip-switch-to-buffer-other-window})
  478. They are used to switch to a specified buffer. Useful for switching to
  479. already existing buffer since buffer name completion is provided. Also
  480. a default buffer will be given as part of the prompt, to which you can
  481. switch by just typing @key{RET} key. @kbd{s} is used to select buffer
  482. in the current window, while @kbd{S} selects buffer in another window.
  483. @item C
  484. @itemx X
  485. @kindex 103 @kbd{C} (@code{vip-ctl-c-equivalent})
  486. @kindex 1300 @kbd{X} (@code{vip-ctl-x-equivalent})
  487. These keys will exit from vi mode and return to emacs mode temporarily.
  488. If you type @kbd{C} (@kbd{X}), Emacs will be in emacs mode and will believe
  489. that you have typed @kbd{C-c} (@kbd{C-x}) in emacs mode. Moreover,
  490. if the following character you type is an upper-case letter, then Emacs
  491. will believe that you have typed the corresponding control character.
  492. You will be in vi mode again after the command is executed. For example,
  493. typing @kbd{X S} in vi mode is the same as typing @kbd{C-x C-s} in emacs
  494. mode. You get the same effect by typing @kbd{C-x C-s} in vi mode, but
  495. the idea here is that you can execute useful Emacs commands without typing
  496. control characters. For example, if you hit @kbd{X} (or @kbd{C-x}) followed
  497. by @kbd{2}, then the current window will be split into 2 and you will be in
  498. vi mode again.
  499. @end table
  500. In addition to these, @code{ctl-x-map} is slightly modified:
  501. @kindex 1301 @kbd{X 3} (@code{vip-buffer-in-two-windows})
  502. @table @kbd
  503. @item X 3
  504. @itemx C-x 3
  505. This is equivalent to @kbd{C-x 1 C-x 2} (1 + 2 = 3).
  506. @end table
  507. @node Window Commands
  508. @subsection Window Commands
  509. In this and following subsections, we give a summary of key bindings for
  510. basic functions related to windows, buffers and files.
  511. @table @kbd
  512. @item C-n
  513. @kindex 016 @kbd{C-n} (@code{vip-next-window})
  514. Switch to next window.
  515. @item X 1
  516. @itemx C-x 1
  517. @kindex 1301 @kbd{X 1} (@code{delete-other-windows})
  518. Delete other windows.
  519. @item X 2
  520. @itemx C-x 2
  521. @kindex 1301 @kbd{X 2} (@code{split-window-vertically})
  522. Split current window into two windows.
  523. @item X 3
  524. @itemx C-x 3
  525. @kindex 1301 @kbd{X 3} (@code{vip-buffer-in-two-windows})
  526. Show current buffer in two windows.
  527. @end table
  528. @node Buffer Commands
  529. @subsection Buffer Commands
  530. @table @kbd
  531. @item s
  532. @kindex 163 @kbd{s} (@code{vip-switch-to-buffer})
  533. Switch to the specified buffer in the current window
  534. (@code{vip-switch-to-buffer}).
  535. @item S
  536. @kindex 123 @kbd{S} (@code{vip-switch-to-buffer-other-window})
  537. Switch to the specified buffer in another window
  538. (@code{vip-switch-to-buffer-other-window}).
  539. @item K
  540. @kindex 113 @kbd{K} (@code{vip-kill-buffer})
  541. Kill the current buffer if it is not modified.
  542. @item X S
  543. @itemx C-x C-s
  544. @kindex 1302 @kbd{X S} (@code{save-buffer})
  545. Save the current buffer in the file associated to the buffer.
  546. @end table
  547. @node File Commands
  548. @subsection File Commands
  549. @table @kbd
  550. @item v
  551. @kindex 166 @kbd{v} (@code{vip-find-file})
  552. Visit specified file in the current window.
  553. @item V
  554. @kindex 126 @kbd{V} (@code{vip-find-file-other-window})
  555. Visit specified file in another window.
  556. @item X W
  557. @itemx C-x C-w
  558. @kindex 1302 @kbd{X W} (@code{write-file})
  559. Write current buffer into the specified file.
  560. @item X I
  561. @itemx C-x C-i
  562. @kindex 1302 @kbd{X I} (@code{insert-file})
  563. Insert specified file at point.
  564. @end table
  565. @node Misc Commands
  566. @subsection Miscellaneous Commands
  567. @table @kbd
  568. @item X (
  569. @itemx C-x (
  570. @kindex 1301 @kbd{X (} (@code{start-kbd-macro})
  571. Start remembering keyboard macro.
  572. @item X )
  573. @itemx C-x )
  574. @kindex 1301 @kbd{X )} (@code{end-kbd-macro})
  575. Finish remembering keyboard macro.
  576. @item *
  577. @kindex 052 @kbd{*} (@code{vip-call-last-kbd-macro})
  578. Call last remembered keyboard macro.
  579. @item X Z
  580. @itemx C-x C-z
  581. @kindex 1302 @kbd{X Z} (@code{suspend-emacs})
  582. Suspend Emacs.
  583. @item Z Z
  584. Exit Emacs.
  585. @item Q
  586. Query replace.
  587. @item R
  588. Replace.
  589. @end table
  590. @node Vi Commands
  591. @chapter Vi Commands
  592. This chapter describes Vi commands other than Ex commands implemented in
  593. VIP@. Except for the last section which discusses insert mode, all the
  594. commands described in this chapter are to be used in vi mode.
  595. @menu
  596. * Numeric Arguments:: Many commands accept numeric arguments
  597. * Important Keys:: Some very important keys.
  598. * Buffers and Windows:: Commands for handling buffers and windows.
  599. * Files:: Commands for handling files.
  600. * Viewing the Buffer:: How you can view the current buffer.
  601. * Mark Commands:: Marking positions in a buffer.
  602. * Motion Commands:: Commands for moving point.
  603. * Searching and Replacing:: Commands for searching and replacing.
  604. * Modifying Commands:: Commands for modifying the buffer.
  605. * Other Vi Commands:: Miscellaneous Commands.
  606. * Commands in Insert Mode:: Commands for entering insert mode.
  607. @end menu
  608. @node Numeric Arguments
  609. @section Numeric Arguments
  610. @cindex numeric arguments
  611. @cindex count
  612. @kindex 061 @kbd{1} (numeric argument)
  613. @kindex 062 @kbd{2} (numeric argument)
  614. @kindex 063 @kbd{3} (numeric argument)
  615. @kindex 064 @kbd{4} (numeric argument)
  616. @kindex 065 @kbd{5} (numeric argument)
  617. @kindex 066 @kbd{6} (numeric argument)
  618. @kindex 067 @kbd{7} (numeric argument)
  619. @kindex 068 @kbd{8} (numeric argument)
  620. @kindex 069 @kbd{9} (numeric argument)
  621. Most Vi commands accept a @dfn{numeric argument} which can be supplied as
  622. a prefix to the commands. A numeric argument is also called a @dfn{count}.
  623. In many cases, if a count is given, the command is executed that many times.
  624. For instance, @kbd{5 d d} deletes 5 lines while simple @kbd{d d} deletes a
  625. line. In this manual the metavariable @var{n} will denote a count.
  626. @node Important Keys
  627. @section Important Keys
  628. The keys @kbd{C-g} and @kbd{C-l} are unique in that their associated
  629. functions are the same in any of emacs, vi and insert mode.
  630. @table @kbd
  631. @item C-g
  632. @kindex 007 @kbd{C-g} (@code{vip-keyboard-quit})
  633. Quit. Cancel running or partially typed command (@code{keyboard-quit}).
  634. @item C-l
  635. @kindex 014 @kbd{C-l} (@code{recenter})
  636. Clear the screen and reprint everything (@code{recenter}).
  637. @end table
  638. In Emacs many commands are bound to the key strokes that start with
  639. @kbd{C-x}, @kbd{C-c} and @key{ESC}. These commands can be
  640. accessed from vi mode as easily as from emacs mode.
  641. @table @kbd
  642. @item C-x
  643. @itemx C-c
  644. @itemx @key{ESC}
  645. @kindex 003 @kbd{C-c} (@code{vip-ctl-c})
  646. @kindex 0300 @kbd{C-x} (@code{vip-ctl-x})
  647. @kindex 033 @kbd{ESC} (@code{vip-ESC})
  648. Typing one of these keys have the same effect as typing it in emacs mode.
  649. Appropriate command will be executed according as the keys you type after
  650. it. You will be in vi mode again after the execution of the command.
  651. For instance, if you type @kbd{@key{ESC} <} (in vi mode) then the cursor will
  652. move to the beginning of the buffer and you will still be in vi mode.
  653. @item C
  654. @itemx X
  655. @kindex 103 @kbd{C} (@code{vip-ctl-c-equivalent})
  656. @kindex 1300 @kbd{X} (@code{vip-ctl-x-equivalent})
  657. Typing one of these keys have the effect of typing the corresponding
  658. control character in emacs mode. Moreover, if you type an upper-case
  659. character following it, that character will also be translated to the
  660. corresponding control character. Thus typing @kbd{X W} in vi mode is the
  661. same as typing @kbd{C-x C-w} in emacs mode. You will be in vi mode again
  662. after the execution of a command.
  663. @item \
  664. @kindex 134 @kbd{\} (@code{vip-escape-to-emacs})
  665. Escape to emacs mode. Hitting the @kbd{\} key will take you to emacs mode,
  666. and you can execute a single Emacs command. After executing the
  667. Emacs command you will be in vi mode again. You can give a count before
  668. typing @kbd{\}. Thus @kbd{5 \ +}, as well as @kbd{\ C-u 5 +}, will insert
  669. @samp{+++++} before point.
  670. @end table
  671. @node Buffers and Windows
  672. @section Buffers and Windows
  673. @cindex buffer
  674. @cindex selected buffer
  675. @cindex current buffer
  676. In Emacs the text you edit is stored in a @dfn{buffer}.
  677. See GNU Emacs Manual, for details. There is always one @dfn{current}
  678. buffer, also called the @dfn{selected buffer}.
  679. @cindex window
  680. @cindex modified (buffer)
  681. You can see the contents of buffers through @dfn{windows} created by Emacs.
  682. When you have multiple windows on the screen only one of them is selected.
  683. Each buffer has a unique name, and each window has a mode line which shows
  684. the name of the buffer associated with the window and other information
  685. about the status of the buffer. You can change the format of the mode
  686. line, but normally if you see @samp{**} at the beginning of a mode line it
  687. means that the buffer is @dfn{modified}. If you write out the content of
  688. the buffer to a file, then the buffer will become not modified. Also if
  689. you see @samp{%%} at the beginning of the mode line, it means that the file
  690. associated with the buffer is write protected.
  691. We have the following commands related to windows and buffers.
  692. @table @kbd
  693. @item C-n
  694. @kindex 016 @kbd{C-n} (@code{vip-next-window})
  695. Move cursor to the next-window (@code{vip-next-window}).
  696. @item X 1
  697. @kindex 1301 @kbd{X 1} (@code{delete-other-windows})
  698. Delete other windows and make the selected window fill the screen
  699. @*(@code{delete-other-windows}).
  700. @item X 2
  701. @kindex 1301 @kbd{X 2} (@code{split-window-vertically})
  702. Split current window into two windows (@code{split-window-vertically}).
  703. @item X 3
  704. @kindex 1301 @kbd{X 3} (@code{vip-buffer-in-two-windows})
  705. Show current buffer in two windows.
  706. @item s @var{buffer} @key{RET}
  707. @kindex 163 @kbd{s} (@code{vip-switch-to-buffer})
  708. Select or create a buffer named @var{buffer} (@code{vip-switch-to-buffer}).
  709. @item S @var{buffer} @key{RET}
  710. @kindex 123 @kbd{S} (@code{vip-switch-to-buffer-other-window})
  711. Similar but select a buffer named @var{buffer} in another window
  712. @*(@code{vip-switch-to-buffer-other-window}).
  713. @item K
  714. @kindex 113 @kbd{K} (@code{vip-kill-buffer})
  715. Kill the current buffer if it is not modified or if it is not associated
  716. with a file @*(@code{vip-kill-buffer}).
  717. @item X B
  718. @kindex 1302 @kbd{X B} (@code{list-buffers})
  719. List the existing buffers (@code{list-buffers}).
  720. @end table
  721. @cindex buffer name completion
  722. As @dfn{buffer name completion} is provided, you have only to type in
  723. initial substring of the buffer name which is sufficient to identify it
  724. among names of existing buffers. After that, if you hit @key{TAB} the rest
  725. of the buffer name will be supplied by the system, and you can confirm it
  726. by @key{RET}. The default buffer name to switch to will also be prompted,
  727. and you can select it by giving a simple @key{RET}. See GNU Emacs Manual
  728. for details of completion.
  729. @node Files
  730. @section Files
  731. We have the following commands related to files. They are used to visit,
  732. save and insert files.
  733. @table @kbd
  734. @item v @var{file} @key{RET}
  735. @kindex 166 @kbd{v} (@code{vip-find-file})
  736. Visit specified file in the current window (@code{vip-find-file}).
  737. @item V @var{file} @key{RET}
  738. @kindex 126 @kbd{V} (@code{vip-find-file-other-window})
  739. Visit specified file in another window (@code{vip-find-file-other-window}).
  740. @item X S
  741. @kindex 1302 @kbd{X S} (@code{save-buffer})
  742. Save current buffer to the file associated with the buffer. If no file is
  743. associated with the buffer, the name of the file to write out the content
  744. of the buffer will be asked in the minibuffer.
  745. @item X W @var{file} @key{RET}
  746. @kindex 1302 @kbd{X W} (@code{write-file})
  747. Write current buffer into a specified file.
  748. @item X I @var{file} @key{RET}
  749. @kindex 1302 @kbd{X I} (@code{insert-file})
  750. Insert a specified file at point.
  751. @item g
  752. @kindex 147 @kbd{g} (@code{vip-info-on-file})
  753. Give information on the file associated with the current buffer. Tell you
  754. the name of the file associated with the buffer, the line number of the
  755. current point and total line numbers in the buffer. If no file is
  756. associated with the buffer, this fact will be indicated by the null file
  757. name @samp{""}.
  758. @end table
  759. @cindex visiting (a file)
  760. @cindex default directory
  761. In Emacs, you can edit a file by @dfn{visiting} it. If you wish to visit a
  762. file in the current window, you can just type @kbd{v}. Emacs maintains the
  763. @dfn{default directory} which is specific to each buffer. Suppose, for
  764. instance, that the default directory of the current buffer is
  765. @file{/usr/masahiko/lisp/}. Then you will get the following prompt in the
  766. minibuffer.
  767. @example
  768. visit file: /usr/masahiko/lisp/
  769. @end example
  770. @noindent
  771. @cindex file name completion
  772. If you wish to visit, say, @file{vip.el} in this directory, then you can
  773. just type @samp{vip.el} followed by @key{RET}. If the file @file{vip.el}
  774. already exists in the directory, Emacs will visit that file, and if not,
  775. the file will be created. Emacs will use the file name (@file{vip.el}, in
  776. this case) as the name of the buffer visiting the file. In order to make
  777. the buffer name unique, Emacs may add a suffix (@pxref{Uniquify,,,
  778. emacs, The GNU Emacs Manual}). As @dfn{file name completion} is provided here, you
  779. can sometimes save typing. For instance, suppose there is only one file in the
  780. default directory whose name starts with @samp{v}, that is @samp{vip.el}.
  781. Then if you just type @kbd{v @key{TAB}} then it will be completed to
  782. @samp{vip.el}. Thus, in this case, you just have to type @kbd{v v @key{TAB}
  783. @key{RET}} to visit @file{/usr/masahiko/lisp/vip.el}. Continuing the
  784. example, let us now suppose that you wished to visit the file
  785. @file{/usr/masahiko/man/vip.texinfo}. Then to the same prompt which you get
  786. after you typed @kbd{v}, you can enter @samp{/usr/masahiko/man/vip.texinfo} or
  787. @samp{../man/vip.texinfo} followed by @key{RET}.
  788. Use @kbd{V} instead of @kbd{v}, if you wish to visit a file in another
  789. window.
  790. You can verify which file you are editing by typing @kbd{g}. (You can also
  791. type @kbd{X B} to get information on other buffers too.) If you type
  792. @kbd{g} you will get an information like below in the echo area:
  793. @example
  794. "/usr/masahiko/man/vip.texinfo" line 921 of 1949
  795. @end example
  796. After you edited the buffer (@samp{vip.texinfo}, in our example) for a while,
  797. you may wish to save it in a file. If you wish to save it in the file
  798. associated with the buffer (@file{/usr/masahiko/man/vip.texinfo}, in this
  799. case), you can just say @kbd{X S}. If you wish to save it in another file,
  800. you can type @kbd{X W}. You will then get a similar prompt as you get for
  801. @kbd{v}, to which you can enter the file name.
  802. @node Viewing the Buffer
  803. @section Viewing the Buffer
  804. In this and next section we discuss commands for moving around in the
  805. buffer. These command do not change the content of the buffer. The
  806. following commands are useful for viewing the content of the current
  807. buffer.
  808. @table @kbd
  809. @item @key{SPC}
  810. @itemx C-f
  811. @kindex 040 @kbd{SPC} (@code{vip-scroll})
  812. @kindex 006 @kbd{C-f} (@code{vip-scroll-back})
  813. Scroll text of current window upward almost full screen. You can go
  814. @i{forward} in the buffer by this command (@code{vip-scroll}).
  815. @item @key{RET}
  816. @itemx C-b
  817. @kindex 015 @kbd{RET} (@code{vip-scroll-back})
  818. @kindex 002 @kbd{C-b} (@code{vip-scroll-back})
  819. Scroll text of current window downward almost full screen. You can go
  820. @i{backward} in the buffer by this command (@code{vip-scroll-back}).
  821. @item C-d
  822. @kindex 004 @kbd{C-d} (@code{vip-scroll-up})
  823. Scroll text of current window upward half screen. You can go
  824. @i{down} in the buffer by this command (@code{vip-scroll-down}).
  825. @item C-u
  826. @kindex 025 @kbd{C-u} (@code{vip-scroll-down})
  827. Scroll text of current window downward half screen. You can go
  828. @i{up} in the buffer by this command (@code{vip-scroll-up}).
  829. @item C-y
  830. @kindex 031 @kbd{C-y} (@code{vip-scroll-down-one})
  831. Scroll text of current window upward by one line (@code{vip-scroll-down-one}).
  832. @item C-e
  833. @kindex 005 @kbd{C-e} (@code{vip-scroll-up-one})
  834. Scroll text of current window downward by one line (@code{vip-scroll-up-one}).
  835. @end table
  836. @noindent
  837. You can repeat these commands by giving a count. Thus, @kbd{2 @key{SPC}}
  838. has the same effect as @kbd{@key{SPC} @key{SPC}}.
  839. The following commands reposition point in the window.
  840. @table @kbd
  841. @item z H
  842. @itemx z @key{RET}
  843. @kindex 1723 @kbd{z H} (@code{vip-line-to-top})
  844. @kindex 1721 @kbd{z RET} (@code{vip-line-to-top})
  845. Put point on the top (@i{home}) line in the window. So the current line
  846. becomes the top line in the window. Given a count @var{n}, point will be
  847. placed in the @var{n}-th line from top (@code{vip-line-to-top}).
  848. @item z M
  849. @itemx z .
  850. @kindex 1723 @kbd{z M} (@code{vip-line-to-middle})
  851. @kindex 1722 @kbd{z .} (@code{vip-line-to-middle})
  852. Put point on the @i{middle} line in the window. Given a count @var{n},
  853. point will be placed in the @var{n}-th line from the middle line
  854. (@code{vip-line-to-middle}).
  855. @item z L
  856. @itemx z -
  857. @kindex 1723 @kbd{z L} (@code{vip-line-to-bottom})
  858. @kindex 1722 @kbd{z -} (@code{vip-line-to-bottom})
  859. Put point on the @i{bottom} line in the window. Given a count @var{n},
  860. point will be placed in the @var{n}-th line from bottom
  861. (@code{vip-line-to-bottom}).
  862. @item C-l
  863. Center point in window and redisplay screen (@code{recenter}).
  864. @end table
  865. @node Mark Commands
  866. @section Mark Commands
  867. The following commands are used to mark positions in the buffer.
  868. @table @kbd
  869. @item m @var{ch}
  870. @kindex 155 @kbd{m} (@code{vip-mark-point})
  871. Store current point in the register @var{ch}. @var{ch} must be a
  872. lower-case @acronym{ASCII} letter.
  873. @item m <
  874. Set mark at the beginning of current buffer.
  875. @item m >
  876. Set mark at the end of current buffer.
  877. @item m .
  878. Set mark at point.
  879. @item m ,
  880. Jump to mark (and pop mark off the mark ring).
  881. @end table
  882. @cindex mark ring
  883. Emacs uses the @dfn{mark ring} to store marked positions. The commands
  884. @kbd{m <}, @kbd{m >} and @kbd{m .}@: not only set mark but also add it as the
  885. latest element of the mark ring (replacing the oldest one). By repeating
  886. the command @kbd{m ,} you can visit older and older marked positions. You
  887. will eventually be in a loop as the mark ring is a ring.
  888. @node Motion Commands
  889. @section Motion Commands
  890. Commands for moving around in the current buffer are collected here. These
  891. commands are used as an ``argument'' for the delete, change and yank commands
  892. to be described in the next section.
  893. @table @kbd
  894. @item h
  895. @kindex 150 @kbd{h} (@code{vip-backward-char})
  896. Move point backward by one character. Signal error if point is at the
  897. beginning of buffer, but (unlike Vi) do not complain otherwise
  898. (@code{vip-backward-char}).
  899. @item l
  900. @kindex 154 @kbd{l} (@code{vip-forward-char})
  901. Move point backward by one character. Signal error if point is at the
  902. end of buffer, but (unlike Vi) do not complain otherwise
  903. (@code{vip-forward-char}).
  904. @item j
  905. @kindex 152 @kbd{j} (@code{vip-next-line})
  906. Move point to the next line keeping the current column. If point is on the
  907. last line of the buffer, a new line will be created and point will move to
  908. that line (@code{vip-next-line}).
  909. @item k
  910. @kindex 153 @kbd{k} (@code{vip-previous-line})
  911. Move point to the previous line keeping the current column
  912. (@code{vip-next-line}).
  913. @item +
  914. @kindex 053 @kbd{+} (@code{vip-next-line-at-bol})
  915. Move point to the next line at the first non-white character. If point is
  916. on the last line of the buffer, a new line will be created and point will
  917. move to the beginning of that line (@code{vip-next-line-at-bol}).
  918. @item -
  919. @kindex 055 @kbd{-} (@code{vip-previous-line-at-bol})
  920. Move point to the previous line at the first non-white character
  921. (@code{vip-previous-line-at-bol}).
  922. @end table
  923. @noindent
  924. If a count is given to these commands, the commands will be repeated that
  925. many times.
  926. @table @kbd
  927. @item 0
  928. @kindex 060 @kbd{0} (@code{vip-beginning-of-line})
  929. Move point to the beginning of line (@code{vip-beginning-of-line}).
  930. @item ^
  931. @kindex 136 @kbd{^} (@code{vip-bol-and-skip-white})
  932. Move point to the first non-white character on the line
  933. (@code{vip-bol-and-skip-white}).
  934. @item $
  935. @kindex 044 @kbd{$} (@code{vip-goto-eol})
  936. Move point to the end of line (@code{vip-goto-eol}).
  937. @item @var{n} |
  938. @kindex 174 @kbd{|} (@code{vip-goto-col})
  939. Move point to the @var{n}-th column on the line (@code{vip-goto-col}).
  940. @end table
  941. @noindent
  942. Except for the @kbd{|} command, these commands neglect a count.
  943. @cindex word
  944. @table @kbd
  945. @item w
  946. @kindex 167 @kbd{w} (@code{vip-forward-word})
  947. Move point forward to the beginning of the next word
  948. (@code{vip-forward-word}).
  949. @item W
  950. @kindex 127 @kbd{W} (@code{vip-forward-Word})
  951. Move point forward to the beginning of the next word, where a @dfn{word} is
  952. considered as a sequence of non-white characters (@code{vip-forward-Word}).
  953. @item b
  954. @kindex 142 @kbd{b} (@code{vip-backward-word})
  955. Move point backward to the beginning of a word (@code{vip-backward-word}).
  956. @item B
  957. @kindex 102 @kbd{B} (@code{vip-backward-Word})
  958. Move point backward to the beginning of a word, where a @i{word} is
  959. considered as a sequence of non-white characters (@code{vip-forward-Word}).
  960. @item e
  961. @kindex 145 @kbd{e} (@code{vip-end-of-word})
  962. Move point forward to the end of a word (@code{vip-end-of-word}).
  963. @item E
  964. @kindex 105 @kbd{E} (@code{vip-end-of-Word})
  965. Move point forward to the end of a word, where a @i{word} is
  966. considered as a sequence of non-white characters (@code{vip-end-of-Word}).
  967. @end table
  968. @noindent
  969. @cindex syntax table
  970. Here the meaning of the word ``word'' for the @kbd{w}, @kbd{b} and @kbd{e}
  971. commands is determined by the @dfn{syntax table} effective in the current
  972. buffer. Each major mode has its syntax mode, and therefore the meaning of
  973. a word also changes as the major mode changes. See GNU Emacs Manual for
  974. details of syntax table.
  975. @table @kbd
  976. @item H
  977. @kindex 110 @kbd{H} (@code{vip-window-top})
  978. Move point to the beginning of the @i{home} (top) line of the window.
  979. Given a count @var{n}, go to the @var{n}-th line from top
  980. (@code{vip-window-top}).
  981. @item M
  982. @kindex 115 @kbd{M} (@code{vip-window-middle})
  983. Move point to the beginning of the @i{middle} line of the window. Given
  984. a count @var{n}, go to the @var{n}-th line from the middle line
  985. (@code{vip-window-middle}).
  986. @item L
  987. @kindex 114 @kbd{L} (@code{vip-window-bottom})
  988. Move point to the beginning of the @i{lowest} (bottom) line of the
  989. window. Given count, go to the @var{n}-th line from bottom
  990. (@code{vip-window-bottom}).
  991. @end table
  992. @noindent
  993. These commands can be used to go to the desired line visible on the screen.
  994. @table @kbd
  995. @item (
  996. @kindex 050 @kbd{(} (@code{vip-backward-sentence})
  997. Move point backward to the beginning of the sentence
  998. (@code{vip-backward-sentence}).
  999. @item )
  1000. @kindex 051 @kbd{)} (@code{vip-forward-sentence})
  1001. Move point forward to the end of the sentence
  1002. (@code{vip-forward-sentence}).
  1003. @item @{
  1004. @kindex 173 @kbd{@{} (@code{vip-backward-paragraph})
  1005. Move point backward to the beginning of the paragraph
  1006. (@code{vip-backward-paragraph}).
  1007. @item @}
  1008. @kindex 175 @kbd{@}} (@code{vip-forward-paragraph})
  1009. Move point forward to the end of the paragraph
  1010. (@code{vip-forward-paragraph}).
  1011. @end table
  1012. @noindent
  1013. A count repeats the effect for these commands.
  1014. @table @kbd
  1015. @item G
  1016. @kindex 107 @kbd{G} (@code{vip-goto-line})
  1017. Given a count @var{n}, move point to the @var{n}-th line in the buffer on
  1018. the first non-white character. Without a count, go to the end of the buffer
  1019. (@code{vip-goto-line}).
  1020. @item ` `
  1021. @kindex 140 @kbd{`} (@code{vip-goto-mark})
  1022. Exchange point and mark (@code{vip-goto-mark}).
  1023. @item ` @var{ch}
  1024. Move point to the position stored in the register @var{ch}. @var{ch} must
  1025. be a lower-case letter.
  1026. @item ' '
  1027. @kindex 047 @kbd{'} (@code{vip-goto-mark-and-skip-white})
  1028. Exchange point and mark, and then move point to the first non-white
  1029. character on the line (@code{vip-goto-mark-and-skip-white}).
  1030. @item ' @var{ch}
  1031. Move point to the position stored in the register @var{ch} and skip to the
  1032. first non-white character on the line. @var{ch} must be a lower-case letter.
  1033. @item %
  1034. @kindex 045 @kbd{%} (@code{vip-paren-match})
  1035. Move point to the matching parenthesis if point is looking at @kbd{(},
  1036. @kbd{)}, @kbd{@{}, @kbd{@}}, @kbd{[} or @kbd{]}
  1037. @*(@code{vip-paren-match}).
  1038. @end table
  1039. @noindent
  1040. The command @kbd{G} mark point before move, so that you can return to the
  1041. original point by @kbd{` `}. The original point will also be stored in
  1042. the mark ring.
  1043. The following commands are useful for moving points on the line. A count
  1044. will repeat the effect.
  1045. @table @kbd
  1046. @item f @var{ch}
  1047. @kindex 146 @kbd{f} (@code{vip-find-char-forward})
  1048. Move point forward to the character @var{ch} on the line. Signal error if
  1049. @var{ch} could not be found (@code{vip-find-char-forward}).
  1050. @item F @var{ch}
  1051. @kindex 106 @kbd{F} (@code{vip-find-char-backward})
  1052. Move point backward to the character @var{ch} on the line. Signal error if
  1053. @var{ch} could not be found (@code{vip-find-char-backward}).
  1054. @item t @var{ch}
  1055. @kindex 164 @kbd{t} (@code{vip-goto-char-forward})
  1056. Move point forward upto the character @var{ch} on the line. Signal error if
  1057. @var{ch} could not be found (@code{vip-goto-char-forward}).
  1058. @item T @var{ch}
  1059. @kindex 124 @kbd{T} (@code{vip-goto-char-backward})
  1060. Move point backward upto the character @var{ch} on the line. Signal error if
  1061. @var{ch} could not be found (@code{vip-goto-char-backward}).
  1062. @item ;
  1063. @kindex 073 @kbd{;} (@code{vip-repeat-find})
  1064. Repeat previous @kbd{f}, @kbd{t}, @kbd{F} or @kbd{T} command
  1065. (@code{vip-repeat-find}).
  1066. @item ,
  1067. @kindex 054 @kbd{,} (@code{vip-repeat-find-opposite})
  1068. Repeat previous @kbd{f}, @kbd{t}, @kbd{F} or @kbd{T} command, in the
  1069. opposite direction (@code{vip-repeat-find-opposite}).
  1070. @end table
  1071. @node Searching and Replacing
  1072. @section Searching and Replacing
  1073. Following commands are available for searching and replacing.
  1074. @cindex regular expression (search)
  1075. @table @kbd
  1076. @item / @var{string} @key{RET}
  1077. @kindex 057 @kbd{/} (@code{vip-search-forward})
  1078. Search the first occurrence of the string @var{string} forward starting
  1079. from point. Given a count @var{n}, the @var{n}-th occurrence of
  1080. @var{string} will be searched. If the variable @code{vip-re-search} has value
  1081. @code{t} then @dfn{regular expression} search is done and the string
  1082. matching the regular expression @var{string} is found. If you give an
  1083. empty string as @var{string} then the search mode will change from vanilla
  1084. search to regular expression search and vice versa
  1085. (@code{vip-search-forward}).
  1086. @item ? @var{string} @key{RET}
  1087. @kindex 077 @kbd{?} (@code{vip-search-backward})
  1088. Same as @kbd{/}, except that search is done backward
  1089. (@code{vip-search-backward}).
  1090. @item n
  1091. @kindex 156 @kbd{n} (@code{vip-search-next})
  1092. Search the previous search pattern in the same direction as before
  1093. (@code{vip-search-next}).
  1094. @item N
  1095. @kindex 116 @kbd{N} (@code{vip-search-Next})
  1096. Search the previous search pattern in the opposite direction
  1097. (@code{vip-search-Next}).
  1098. @item C-s
  1099. @kindex 023 @kbd{C-s} (@code{isearch-forward})
  1100. Search forward incrementally. See GNU Emacs Manual for details
  1101. (@code{isearch-forward}).
  1102. @item C-r
  1103. @kindex 022 @kbd{C-r} (@code{isearch-backward})
  1104. Search backward incrementally (@code{isearch-backward}).
  1105. @cindex vanilla (replacement)
  1106. @cindex regular expression (replacement)
  1107. @item R @var{string} RET @var{newstring}
  1108. @kindex 122 @kbd{R} (@code{vip-replace-string})
  1109. There are two modes of replacement, @dfn{vanilla} and @dfn{regular expression}.
  1110. If the mode is @i{vanilla} you will get a prompt @samp{Replace string:},
  1111. and if the mode is @i{regular expression} you will ge a prompt
  1112. @samp{Replace regexp:}. The mode is initially @i{vanilla}, but you can
  1113. toggle these modes by giving a null string as @var{string}. If the mode is
  1114. vanilla, this command replaces every occurrence of @var{string} with
  1115. @var{newstring}. If the mode is regular expression, @var{string} is
  1116. treated as a regular expression and every string matching the regular
  1117. expression is replaced with @var{newstring} (@code{vip-replace-string}).
  1118. @item Q @var{string} RET @var{newstring}
  1119. @kindex 121 @kbd{Q} (@code{vip-query-replace})
  1120. Same as @kbd{R} except that you will be asked form confirmation before each
  1121. replacement
  1122. @*(@code{vip-query-replace}).
  1123. @item r @var{ch}
  1124. @kindex 162 @kbd{r} (@code{vip-replace-char})
  1125. Replace the character point is looking at by the character @var{ch}. Give
  1126. count, replace that many characters by @var{ch} (@code{vip-replace-char}).
  1127. @end table
  1128. @noindent
  1129. The commands @kbd{/} and @kbd{?} mark point before move, so that you can
  1130. return to the original point by @w{@kbd{` `}}.
  1131. @node Modifying Commands
  1132. @section Modifying Commands
  1133. In this section, commands for modifying the content of a buffer are
  1134. described. These commands affect the region determined by a motion command
  1135. which is given to the commands as their argument.
  1136. @cindex point commands
  1137. @cindex line commands
  1138. We classify motion commands into @dfn{point commands} and
  1139. @dfn{line commands}. The point commands are as follows:
  1140. @example
  1141. @kbd{h}, @kbd{l}, @kbd{0}, @kbd{^}, @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B}, @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f}, @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}
  1142. @end example
  1143. @noindent
  1144. The line commands are as follows:
  1145. @example
  1146. @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{}, @kbd{@}}, @kbd{G}, @kbd{'}
  1147. @end example
  1148. @noindent
  1149. @cindex expanding (region)
  1150. If a point command is given as an argument to a modifying command, the
  1151. region determined by the point command will be affected by the modifying
  1152. command. On the other hand, if a line command is given as an argument to a
  1153. modifying command, the region determined by the line command will be
  1154. enlarged so that it will become the smallest region properly containing the
  1155. region and consisting of whole lines (we call this process @dfn{expanding
  1156. the region}), and then the enlarged region will be affected by the modifying
  1157. command.
  1158. @menu
  1159. * Delete Commands:: Commands for deleting text.
  1160. * Yank Commands:: Commands for yanking text in Vi's sense.
  1161. * Put Back Commands:: Commands for putting back deleted/yanked text.
  1162. * Change Commands:: Commands for changing text.
  1163. * Repeating and Undoing Modifications::
  1164. @end menu
  1165. @node Delete Commands
  1166. @subsection Delete Commands
  1167. @table @kbd
  1168. @item d @var{motion-command}
  1169. @kindex 1440 @kbd{d} (@code{vip-command-argument})
  1170. Delete the region determined by the motion command @var{motion-command}.
  1171. @end table
  1172. @noindent
  1173. For example, @kbd{d $} will delete the region between point and end of
  1174. current line since @kbd{$} is a point command that moves point to end of line.
  1175. @kbd{d G} will delete the region between the beginning of current line and
  1176. end of the buffer, since @kbd{G} is a line command. A count given to the
  1177. command above will become the count for the associated motion command.
  1178. Thus, @kbd{3 d w} will delete three words.
  1179. @kindex 042 @kbd{"} (@code{vip-command-argument})
  1180. It is also possible to save the deleted text into a register you specify.
  1181. For example, you can say @kbd{" t 3 d w} to delete three words and save it
  1182. to register @kbd{t}. The name of a register is a lower-case letter between
  1183. @kbd{a} and @kbd{z}. If you give an upper-case letter as an argument to
  1184. a delete command, then the deleted text will be appended to the content of
  1185. the register having the corresponding lower-case letter as its name. So,
  1186. @kbd{" T d w} will delete a word and append it to register @kbd{t}. Other
  1187. modifying commands also accept a register name as their argument, and we
  1188. will not repeat similar explanations.
  1189. We have more delete commands as below.
  1190. @table @kbd
  1191. @item d d
  1192. @kindex 1442 @kbd{d d}
  1193. Delete a line. Given a count @var{n}, delete @var{n} lines.
  1194. @item d r
  1195. @kindex 1442 @kbd{d r}
  1196. Delete current region.
  1197. @item d R
  1198. @kindex 1441 @kbd{d R}
  1199. Expand current region and delete it.
  1200. @item D
  1201. @kindex 104 @kbd{D} (@code{vip-kill-line})
  1202. Delete to the end of a line (@code{vip-kill-line}).
  1203. @item x
  1204. @kindex 170 @kbd{x} (@code{vip-delete-char})
  1205. Delete a character after point. Given @var{n}, delete @var{n} characters
  1206. (@code{vip-delete-char}).
  1207. @item @key{DEL}
  1208. @kindex 177 @kbd{DEL} (@code{vip-delete-backward-char})
  1209. Delete a character before point. Given @var{n}, delete @var{n} characters
  1210. (@code{vip-delete-backward-char}).
  1211. @end table
  1212. @node Yank Commands
  1213. @subsection Yank Commands
  1214. @cindex yank
  1215. Yank commands @dfn{yank} a text of buffer into a (usually anonymous) register.
  1216. Here the word ``yank'' is used in Vi's sense. Thus yank commands do not
  1217. alter the content of the buffer, and useful only in combination with
  1218. commands that put back the yanked text into the buffer.
  1219. @table @kbd
  1220. @item y @var{motion-command}
  1221. @kindex 1710 @kbd{y} (@code{vip-command-argument})
  1222. Yank the region determined by the motion command @var{motion-command}.
  1223. @end table
  1224. @noindent
  1225. For example, @kbd{y $} will yank the text between point and the end of line
  1226. into an anonymous register, while @kbd{"c y $} will yank the same text into
  1227. register @kbd{c}.
  1228. Use the following command to yank consecutive lines of text.
  1229. @table @kbd
  1230. @item y y
  1231. @itemx Y
  1232. @kindex 131 @kbd{Y} (@code{vip-yank-line})
  1233. @kindex 1712 @kbd{y y} (@code{vip-yank-line})
  1234. Yank a line. Given @var{n}, yank @var{n} lines (@code{vip-yank-line}).
  1235. @item y r
  1236. @kindex 1712 @kbd{y r}
  1237. Yank current region.
  1238. @item y R
  1239. @kindex 1711 @kbd{y R}
  1240. Expand current region and yank it.
  1241. @end table
  1242. @node Put Back Commands
  1243. @subsection Put Back Commands
  1244. Deleted or yanked texts can be put back into the buffer by the command
  1245. below.
  1246. @table @kbd
  1247. @item p
  1248. @kindex 160 @kbd{p} (@code{vip-put-back})
  1249. Insert, after the character point is looking at, most recently
  1250. deleted/yanked text from anonymous register. Given a register name
  1251. argument, the content of the named register will be put back. Given a
  1252. count, the command will be repeated that many times. This command also
  1253. checks if the text to put back ends with a new line character, and if so
  1254. the text will be put below the current line (@code{vip-put-back}).
  1255. @item P
  1256. @kindex 120 @kbd{P} (@code{vip-Put-back})
  1257. Insert at point most recently deleted/yanked text from anonymous register.
  1258. Given a register name argument, the content of the named register will
  1259. be put back. Given a count, the command will be repeated that many times.
  1260. This command also checks if the text to put back ends with a new line
  1261. character, and if so the text will be put above the current line rather
  1262. than at point (@code{vip-Put-back}).
  1263. @end table
  1264. @noindent
  1265. @cindex number register
  1266. Thus, @kbd{" c p} will put back the content of the register @kbd{c} into the
  1267. buffer. It is also possible to specify @dfn{number register} which is a
  1268. numeral between @kbd{1} and @kbd{9}. If the number register @var{n} is
  1269. specified, @var{n}-th previously deleted/yanked text will be put back. It
  1270. is an error to specify a number register for the delete/yank commands.
  1271. @node Change Commands
  1272. @subsection Change Commands
  1273. Most commonly used change command takes the following form.
  1274. @table @kbd
  1275. @item c @var{motion-command}
  1276. @kindex 1430 @kbd{c} (@code{vip-command-argument})
  1277. Replace the content of the region determined by the motion command
  1278. @var{motion-command} by the text you type. If the motion command is a
  1279. point command then you will type the text into minibuffer, and if the
  1280. motion command is a line command then the region will be deleted first and
  1281. you can insert the text in @var{insert mode}.
  1282. @end table
  1283. @noindent
  1284. For example, if point is at the beginning of a word @samp{foo} and you
  1285. wish to change it to @samp{bar}, you can type @kbd{c w}. Then, as @kbd{w}
  1286. is a point command, you will get the prompt @samp{foo =>} in the
  1287. minibuffer, for which you can type @kbd{b a r @key{RET}} to complete the change
  1288. command.
  1289. @table @kbd
  1290. @item c c
  1291. @kindex 1432 @kbd{c c}
  1292. Change a line. Given a count, that many lines are changed.
  1293. @item c r
  1294. @kindex 1432 @kbd{c r}
  1295. Change current region.
  1296. @item c R
  1297. @kindex 1431 @kbd{c R}
  1298. Expand current region and change it.
  1299. @end table
  1300. @node Repeating and Undoing Modifications
  1301. @subsection Repeating and Undoing Modifications
  1302. VIP records the previous modifying command, so that it is easy to repeat
  1303. it. It is also very easy to undo changes made by modifying commands.
  1304. @table @kbd
  1305. @item u
  1306. @kindex 165 @kbd{u} (@code{vip-undo})
  1307. Undo the last change. You can undo more by repeating undo by the repeat
  1308. command @samp{.}. For example, you can undo 5 previous changes by typing
  1309. @samp{u....}. If you type @samp{uu}, then the second @samp{u} undoes the
  1310. first undo command (@code{vip-undo}).
  1311. @item .
  1312. @kindex 056 @kbd{.} (@code{vip-repeat})
  1313. Repeat the last modifying command. Given count @var{n} it becomes the new
  1314. count for the repeated command. Otherwise, the count for the last
  1315. modifying command is used again (@code{vip-repeat}).
  1316. @end table
  1317. @node Other Vi Commands
  1318. @section Other Vi Commands
  1319. Miscellaneous Vi commands are collected here.
  1320. @table @kbd
  1321. @item Z Z
  1322. @kindex 132 @kbd{Z Z} (@code{save-buffers-kill-emacs})
  1323. Exit Emacs. If modified buffers exist, you will be asked whether you wish
  1324. to save them or not (@code{save-buffers-kill-emacs}).
  1325. @item !@: @var{motion-command} @var{format-command}
  1326. @itemx @var{n} !@: !@: @var{format-command}
  1327. @kindex 041 @kbd{!} (@code{vip-command-argument})
  1328. The region determined by the motion command @var{motion-command} will be
  1329. given to the shell command @var{format-command} and the region will be
  1330. replaced by its output. If a count is given, it will be passed to
  1331. @var{motion-command}. For example, @samp{3!Gsort} will sort the region
  1332. between point and the 3rd line. If @kbd{!} is used instead of
  1333. @var{motion-command} then @var{n} lines will be processed by
  1334. @var{format-command} (@code{vip-command-argument}).
  1335. @item J
  1336. @kindex 112 @kbd{J} (@code{vip-join-lines})
  1337. Join two lines. Given count, join that many lines. A space will be
  1338. inserted at each junction (@code{vip-join-lines}).
  1339. @item < @var{motion-command}
  1340. @itemx @var{n} < <
  1341. @kindex 074 @kbd{<} (@code{vip-command-argument})
  1342. Shift region determined by the motion command @var{motion-command} to
  1343. left by @var{shift-width} (default is 8). If @kbd{<} is used instead of
  1344. @var{motion-command} then shift @var{n} lines
  1345. @*(@code{vip-command-argument}).
  1346. @item > @var{motion-command}
  1347. @itemx @var{n} > >
  1348. @kindex 076 @kbd{>} (@code{vip-command-argument})
  1349. Shift region determined by the motion command @var{motion-command} to
  1350. right by @var{shift-width} (default is 8). If @kbd{<} is used instead of
  1351. @var{motion-command} then shift @var{n} lines
  1352. @*(@code{vip-command-argument}).
  1353. @item = @var{motion-command}
  1354. @kindex 075 @kbd{=} (@code{vip-command-argument})
  1355. Indent region determined by the motion command @var{motion-command}. If
  1356. @kbd{=} is used instead of @var{motion-command} then indent @var{n} lines
  1357. (@code{vip-command-argument}).
  1358. @item *
  1359. @kindex 052 @kbd{*} (@code{vip-call-last-kbd-macro})
  1360. Call last remembered keyboard macro.
  1361. @item #
  1362. A new vi operator. @xref{New Commands}, for more details.
  1363. @end table
  1364. The following keys are reserved for future extensions, and currently
  1365. assigned to a function that just beeps (@code{vip-nil}).
  1366. @kindex 046 @kbd{&} (@code{vip-nil})
  1367. @kindex 100 @kbd{@@} (@code{vip-nil})
  1368. @kindex 125 @kbd{U} (@code{vip-nil})
  1369. @kindex 133 @kbd{[} (@code{vip-nil})
  1370. @kindex 135 @kbd{]} (@code{vip-nil})
  1371. @kindex 137 @kbd{_} (@code{vip-nil})
  1372. @kindex 161 @kbd{q} (@code{vip-nil})
  1373. @kindex 176 @kbd{~} (@code{vip-nil})
  1374. @example
  1375. &, @@, U, [, ], _, q, ~
  1376. @end example
  1377. VIP uses a special local keymap to interpret key strokes you enter in vi
  1378. mode. The following keys are bound to @code{nil} in the keymap. Therefore,
  1379. these keys are interpreted by the global keymap of Emacs. We give below a
  1380. short description of the functions bound to these keys in the global
  1381. keymap. See GNU Emacs Manual for details.
  1382. @table @kbd
  1383. @item C-@@
  1384. @kindex 000 @kbd{C-@@} (@code{set-mark-command})
  1385. Set mark and push previous mark on mark ring (@code{set-mark-command}).
  1386. @item TAB
  1387. @kindex 011 TAB (@code{indent-for-tab-command})
  1388. Indent line for current major mode (@code{indent-for-tab-command}).
  1389. @item C-j
  1390. @kindex 012 @kbd{C-j} (@code{electric-newline-and-maybe-indent})
  1391. Insert a newline, and maybe indent according to mode.
  1392. @item C-k
  1393. @kindex 013 @kbd{C-k} (@code{kill-line})
  1394. Kill the rest of the current line; before a newline, kill the newline.
  1395. With a numeric argument, kill that many lines from point. Negative arguments
  1396. kill lines backward (@code{kill-line}).
  1397. @item C-l
  1398. @kindex 014 @kbd{C-l} (@code{recenter})
  1399. Clear the screen and reprint everything (@code{recenter}).
  1400. @item @var{n} C-p
  1401. @kindex 020 @kbd{C-p} (@code{previous-line})
  1402. Move cursor vertically up @var{n} lines (@code{previous-line}).
  1403. @item C-q
  1404. @kindex 021 @kbd{C-q} (@code{quoted-insert})
  1405. Read next input character and insert it. Useful for inserting control
  1406. characters
  1407. @*(@code{quoted-insert}).
  1408. @item C-r
  1409. @kindex 022 @kbd{C-r} (@code{isearch-backward})
  1410. Search backward incrementally (@code{isearch-backward}).
  1411. @item C-s
  1412. @kindex 023 @kbd{C-s} (@code{isearch-forward})
  1413. Search forward incrementally (@code{isearch-forward}).
  1414. @item @var{n} C-t
  1415. @kindex 024 @kbd{C-t} (@code{transpose-chars})
  1416. Interchange characters around point, moving forward one character. With
  1417. count @var{n}, take character before point and drag it forward past @var{n}
  1418. other characters. If no argument and at end of line, the previous two
  1419. characters are exchanged (@code{transpose-chars}).
  1420. @item @var{n} C-v
  1421. @kindex 026 @kbd{C-v} (@code{scroll-up})
  1422. Scroll text upward @var{n} lines. If @var{n} is not given, scroll near
  1423. full screen (@code{scroll-up}).
  1424. @item C-w
  1425. @kindex 027 @kbd{C-w} (@code{kill-region})
  1426. Kill between point and mark. The text is save in the kill ring. The
  1427. command @kbd{P} or @kbd{p} can retrieve it from kill ring
  1428. (@code{kill-region}).
  1429. @end table
  1430. @node Commands in Insert Mode
  1431. @section Insert Mode
  1432. You can enter insert mode by one of the following commands. In addition to
  1433. these, you will enter insert mode if you give a change command with a line
  1434. command as the motion command. Insert commands are also modifying commands
  1435. and you can repeat them by the repeat command @kbd{.} (@code{vip-repeat}).
  1436. @table @kbd
  1437. @item i
  1438. @kindex 151 @kbd{i} (@code{vip-insert})
  1439. Enter insert mode at point (@code{vip-insert}).
  1440. @item I
  1441. @kindex 111 @kbd{I} (@code{vip-Insert})
  1442. Enter insert mode at the first non white character on the line
  1443. (@code{vip-Insert}).
  1444. @item a
  1445. @kindex 141 @kbd{a} (@code{vip-append})
  1446. Move point forward by one character and then enter insert mode
  1447. (@code{vip-append}).
  1448. @item A
  1449. @kindex 101 @kbd{A} (@code{vip-Append})
  1450. Enter insert mode at end of line (@code{vip-Append}).
  1451. @item o
  1452. @kindex 157 @kbd{o} (@code{vip-open-line})
  1453. Open a new line below the current line and enter insert mode
  1454. (@code{vip-open-line}).
  1455. @item O
  1456. @kindex 117 @kbd{O} (@code{vip-Open-line})
  1457. Open a new line above the current line and enter insert mode
  1458. (@code{vip-Open-line}).
  1459. @item C-o
  1460. @kindex 017 @kbd{C-o} (@code{vip-open-line-at-point})
  1461. Insert a newline and leave point before it, and then enter insert mode
  1462. @*(@code{vip-open-line-at-point}).
  1463. @end table
  1464. Insert mode is almost like emacs mode. Only the following 4 keys behave
  1465. differently from emacs mode.
  1466. @table @kbd
  1467. @item @key{ESC}
  1468. @kindex 033 @kbd{ESC} (@code{vip-change-mode-to-vi}) (insert mode)
  1469. This key will take you back to vi mode (@code{vip-change-mode-to-vi}).
  1470. @item C-h
  1471. @kindex 010 @kbd{C-h} (@code{delete-backward-char}) (insert mode)
  1472. Delete previous character (@code{delete-backward-char}).
  1473. @item C-w
  1474. @kindex 027 @kbd{C-w} (@code{vip-delete-backward-word}) (insert mode)
  1475. Delete previous word (@code{vip-delete-backward-word}).
  1476. @item C-z
  1477. @kindex 032 @kbd{C-z} (@code{vip-ESC}) (insert mode)
  1478. This key simulates @key{ESC} key in emacs mode. For instance, typing
  1479. @kbd{C-z x} in insert mode is the same as typing @kbd{ESC x} in emacs mode
  1480. (@code{vip-ESC}).
  1481. @end table
  1482. @noindent
  1483. You can also bind @kbd{C-h} to @code{help-command} if you like.
  1484. (@xref{Customizing Key Bindings}, for details.) Binding @kbd{C-h} to
  1485. @code{help-command} has the effect of making the meaning of @kbd{C-h}
  1486. uniform among emacs, vi and insert modes.
  1487. When you enter insert mode, VIP records point as the start point of
  1488. insertion, and when you leave insert mode the region between point and
  1489. start point is saved for later use by repeat command etc. Therefore, repeat
  1490. command will not really repeat insertion if you move point by emacs
  1491. commands while in insert mode.
  1492. @node Ex Commands
  1493. @chapter Ex Commands
  1494. @kindex 072 @kbd{:} (@code{vip-ex})
  1495. In vi mode, you can execute an Ex command @var{ex-command} by typing:
  1496. @example
  1497. @kbd{:@: @var{ex-command} @key{RET}}
  1498. @end example
  1499. Every Ex command follows the following pattern:
  1500. @example
  1501. @var{address command} @kbd{!}@: @var{parameters count flags}
  1502. @end example
  1503. @noindent
  1504. @cindex address
  1505. where all parts are optional. For the syntax of @dfn{address}, the reader
  1506. is referred to the reference manual of Ex.
  1507. @cindex magic
  1508. @cindex regular expression
  1509. In the current version of VIP, searching by Ex commands is always
  1510. @dfn{magic}. That is, search patterns are always treated as @dfn{regular
  1511. expressions}. For example, a typical forward search would be invoked by
  1512. @kbd{:/@var{pat}/}. If you wish to include @samp{/} as part of
  1513. @var{pat} you must preceded it by @samp{\}. VIP strips off these @kbd{\}'s
  1514. before @kbd{/} and the resulting @var{pat} becomes the actual search
  1515. pattern. Emacs provides a different and richer class or regular
  1516. expressions than Vi/Ex, and VIP uses Emacs's regular expressions. See GNU
  1517. Emacs Manual for details of regular expressions.
  1518. Several Ex commands can be entered in a line by separating them by a pipe
  1519. character @samp{|}.
  1520. @menu
  1521. * Ex Command Reference:: Explain all the Ex commands available in VIP.
  1522. @end menu
  1523. @node Ex Command Reference
  1524. @section Ex Command Reference
  1525. In this section we briefly explain all the Ex commands supported by VIP@.
  1526. Most Ex commands expect @var{address} as their argument, and they use
  1527. default addresses if they are not explicitly given. In the following, such
  1528. default addresses will be shown in parentheses.
  1529. Most command names can and preferably be given in abbreviated forms. In
  1530. the following, optional parts of command names will be enclosed in
  1531. brackets. For example, @samp{co[py]} will mean that copy command can be
  1532. give as @samp{co} or @samp{cop} or @samp{copy}.
  1533. If @var{command} is empty, point will move to the beginning of the line
  1534. specified by the @var{address}. If @var{address} is also empty, point will
  1535. move to the beginning of the current line.
  1536. @cindex flag
  1537. Some commands accept @dfn{flags} which are one of @kbd{p}, @kbd{l} and
  1538. @kbd{#}. If @var{flags} are given, the text affected by the commands will
  1539. be displayed on a temporary window, and you will be asked to hit return to
  1540. continue. In this way, you can see the text affected by the commands
  1541. before the commands will be executed. If you hit @kbd{C-g} instead of
  1542. @key{RET} then the commands will be aborted. Note that the meaning of
  1543. @var{flags} is different in VIP from that in Vi/Ex.
  1544. @table @kbd
  1545. @item (.,.@:) co[py] @var{addr} @var{flags}
  1546. @itemx (.,.@:) t @var{addr} @var{flags}
  1547. Place a copy of specified lines after @var{addr}. If @var{addr} is
  1548. @kbd{0}, it will be placed before the first line.
  1549. @item (.,.@:) d[elete] @var{register} @var{count} @var{flags}
  1550. Delete specified lines. Text will be saved in a named @var{register} if a
  1551. lower-case letter is given, and appended to a register if a capital letter is
  1552. given.
  1553. @item e[dit] !@: +@var{addr} @var{file}
  1554. @itemx e[x] !@: +@var{addr} @var{file}
  1555. @itemx vi[sual] !@: +@var{addr} @var{file}
  1556. Edit a new file @var{file} in the current window. The command will abort
  1557. if current buffer is modified, which you can override by giving @kbd{!}.
  1558. If @kbd{+}@var{addr} is given, @var{addr} becomes the current line.
  1559. @item file
  1560. Give information about the current file.
  1561. @item (1,$) g[lobal] !@: /@var{pat}/ @var{cmds}
  1562. @itemx (1,$) v /@var{pat}/ @var{cmds}
  1563. Among specified lines first mark each line which matches the regular
  1564. expression @var{pat}, and then execute @var{cmds} on each marked line.
  1565. If @kbd{!}@: is given, @var{cmds} will be executed on each line not matching
  1566. @var{pat}. @kbd{v} is same as @kbd{g!}.
  1567. @item (.,.+1) j[oin] !@: @var{count} @var{flags}
  1568. Join specified lines into a line. Without @kbd{!}, a space character will
  1569. be inserted at each junction.
  1570. @item (.@:) k @var{ch}
  1571. @itemx (.@:) mar[k] @var{ch}
  1572. Mark specified line by a lower-case character @var{ch}. Then the
  1573. addressing form @kbd{'}@var{ch} will refer to this line. No white space is
  1574. required between @kbd{k} and @var{ch}. A white space is necessary between
  1575. @kbd{mark} and @var{ch}, however.
  1576. @item map @var{ch} @var{rhs}
  1577. Define a macro for vi mode. After this command, the character @var{ch}
  1578. will be expanded to @var{rhs} in vi mode.
  1579. @item (.,.@:) m[ove] @var{addr}
  1580. Move specified lines after @var{addr}.
  1581. @item (.@:) pu[t] @var{register}
  1582. Put back previously deleted or yanked text. If @var{register} is given,
  1583. the text saved in the register will be put back; otherwise, last deleted or
  1584. yanked text will be put back.
  1585. @item q[uit] !
  1586. Quit from Emacs. If modified buffers with associated files exist, you will
  1587. be asked whether you wish to save each of them. At this point, you may
  1588. choose not to quit, by hitting @kbd{C-g}. If @kbd{!}@: is given, exit from
  1589. Emacs without saving modified buffers.
  1590. @item (.@:) r[ead] @var{file}
  1591. Read in the content of the file @var{file} after the specified line.
  1592. @item (.@:) r[ead] !@: @var{command}
  1593. Read in the output of the shell command @var{command} after the specified
  1594. line.
  1595. @item se[t]
  1596. Set a variable's value. @xref{Customizing Constants}, for the list of variables
  1597. you can set.
  1598. @item sh[ell]
  1599. Run a subshell in a window.
  1600. @item (.,.@:) s[ubstitute] /@var{pat}/@var{repl}/ @var{options} @var{count} @var{flags}
  1601. @itemx (.,.@:) & @var{options} @var{count} @var{flags}
  1602. On each specified line, the first occurrence of string matching regular
  1603. expression @var{pat} is replaced by replacement pattern @var{repl}. Option
  1604. characters are @kbd{g} and @kbd{c}. If global option character @kbd{g}
  1605. appears as part of @var{options}, all occurrences are substituted. If
  1606. confirm option character @kbd{c} appears, you will be asked to give
  1607. confirmation before each substitution. If @kbd{/@var{pat}/@var{repl}/} is
  1608. missing, the last substitution is repeated.
  1609. @item st[op]
  1610. Suspend Emacs.
  1611. @item ta[g] @var{tag}
  1612. @cindex tag
  1613. @cindex selected tags table
  1614. Find first definition of @var{tag}. If no @var{tag} is given, previously
  1615. given @var{tag} is used and next alternate definition is find. By default,
  1616. the file @file{TAGS} in the current directory becomes the @dfn{selected tags
  1617. table}. You can select another tags table by @kbd{set} command.
  1618. @xref{Customizing Constants}, for details.
  1619. @item und[o]
  1620. Undo the last change.
  1621. @item unm[ap] @var{ch}
  1622. The macro expansion associated with @var{ch} is removed.
  1623. @item ve[rsion]
  1624. Tell the version number of VIP.
  1625. @item (1,$) w[rite] !@: @var{file}
  1626. Write out specified lines into file @var{file}. If no @var{file} is given,
  1627. text will be written to the file associated to the current buffer. Unless
  1628. @kbd{!}@: is given, if @var{file} is different from the file associated to
  1629. the current buffer and if the file @var{file} exists, the command will not
  1630. be executed. Unlike Ex, @var{file} becomes the file associated to the
  1631. current buffer.
  1632. @item (1,$) w[rite]>> @var{file}
  1633. Write out specified lines at the end of file @var{file}. @var{file}
  1634. becomes the file associated to the current buffer.
  1635. @item (1,$) wq !@: @var{file}
  1636. Same as @kbd{write} and then @kbd{quit}. If @kbd{!}@: is given, same as
  1637. @kbd{write !}@: then @kbd{quit}.
  1638. @item (.,.) y[ank] @var{register} @var{count}
  1639. Save specified lines into register @var{register}. If no register is
  1640. specified, text will be saved in an anonymous register.
  1641. @item @var{addr} !@: @var{command}
  1642. Execute shell command @var{command}. The output will be shown in a new
  1643. window. If @var{addr} is given, specified lines will be used as standard
  1644. input to @var{command}.
  1645. @item ($) =
  1646. Print the line number of the addressed line.
  1647. @item (.,.) > @var{count} @var{flags}
  1648. Shift specified lines to the right. The variable @code{vip-shift-width}
  1649. (default value is 8) determines the amount of shift.
  1650. @item (.,.) < @var{count} @var{flags}
  1651. Shift specified lines to the left. The variable @code{vip-shift-width}
  1652. (default value is 8) determines the amount of shift.
  1653. @item (.,.@:) ~ @var{options} @var{count} @var{flags}
  1654. Repeat the previous @kbd{substitute} command using previous search pattern
  1655. as @var{pat} for matching.
  1656. @end table
  1657. The following Ex commands are available in Vi, but not implemented in VIP.
  1658. @example
  1659. @kbd{abbreviate}, @kbd{list}, @kbd{next}, @kbd{print}, @kbd{preserve}, @kbd{recover}, @kbd{rewind}, @kbd{source},
  1660. @kbd{unabbreviate}, @kbd{xit}, @kbd{z}
  1661. @end example
  1662. @node Customization
  1663. @chapter Customization
  1664. If you have a file called @file{~/.emacs.d/vip} (or @file{~/.vip}), then it
  1665. will also be loaded when VIP is loaded. This file is thus useful for
  1666. customizing VIP.
  1667. @menu
  1668. * Customizing Constants:: How to change values of constants.
  1669. * Customizing Key Bindings:: How to change key bindings.
  1670. @end menu
  1671. @node Customizing Constants
  1672. @section Customizing Constants
  1673. An easy way to customize VIP is to change the values of constants used
  1674. in VIP@. Here is the list of the constants used in VIP and their default
  1675. values.
  1676. @table @code
  1677. @item vip-shift-width 8
  1678. The number of columns shifted by @kbd{>} and @kbd{<} command.
  1679. @item vip-re-replace nil
  1680. If @code{t} then do regexp replace, if @code{nil} then do string replace.
  1681. @item vip-search-wrap-around t
  1682. If @code{t}, search wraps around the buffer.
  1683. @item vip-re-search nil
  1684. If @code{t} then search is reg-exp search, if @code{nil} then vanilla
  1685. search.
  1686. @item vip-case-fold-search nil
  1687. If @code{t} search ignores cases.
  1688. @item vip-re-query-replace nil
  1689. If @code{t} then do reg-exp replace in query replace.
  1690. @item vip-open-with-indent nil
  1691. If @code{t} then indent to the previous current line when open a new line
  1692. by @kbd{o} or @kbd{O} command.
  1693. @item vip-tags-file-name "TAGS"
  1694. The name of the file used as the tags table.
  1695. @item vip-help-in-insert-mode nil
  1696. If @code{t} then @key{C-h} is bound to @code{help-command} in insert mode,
  1697. if @code{nil} then it sis bound to @code{delete-backward-char}.
  1698. @end table
  1699. @noindent
  1700. You can reset these constants in VIP by the Ex command @kbd{set}. Or you
  1701. can include a line like this in your @file{~/.emacs.d/vip} file:
  1702. @example
  1703. (setq vip-case-fold-search t)
  1704. @end example
  1705. @node Customizing Key Bindings
  1706. @section Customizing Key Bindings
  1707. @cindex local keymap
  1708. VIP uses @code{vip-command-mode-map} as the @dfn{local keymap} for vi mode.
  1709. For example, in vi mode, @key{SPC} is bound to the function
  1710. @code{vip-scroll}. But, if you wish to make @key{SPC} and some other keys
  1711. behave like Vi, you can include the following lines in your
  1712. @file{~/.emacs.d/vip} file.
  1713. @example
  1714. (define-key vip-command-mode-map "\C-g" 'vip-info-on-file)
  1715. (define-key vip-command-mode-map "\C-h" 'vip-backward-char)
  1716. (define-key vip-command-mode-map "\C-m" 'vip-next-line-at-bol)
  1717. (define-key vip-command-mode-map " " 'vip-forward-char)
  1718. (define-key vip-command-mode-map "g" 'vip-keyboard-quit)
  1719. (define-key vip-command-mode-map "s" 'vip-substitute)
  1720. (define-key vip-command-mode-map "C" 'vip-change-to-eol)
  1721. (define-key vip-command-mode-map "R" 'vip-change-to-eol)
  1722. (define-key vip-command-mode-map "S" 'vip-substitute-line)
  1723. (define-key vip-command-mode-map "X" 'vip-delete-backward-char)
  1724. @end example
  1725. @node GNU Free Documentation License
  1726. @appendix GNU Free Documentation License
  1727. @include doclicense.texi
  1728. @unnumbered Key Index
  1729. @printindex ky
  1730. @unnumbered Concept Index
  1731. @printindex cp
  1732. @bye