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