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