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