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