viper.texi 176 KB
Newer Older
Glenn Morris's avatar
Glenn Morris committed
1 2 3 4 5 6
% -*-texinfo-*-
\input texinfo

@comment Using viper.info instead of viper in setfilename breaks DOS.
@comment @setfilename viper
@comment @setfilename viper.info
7
@setfilename ../../info/viper.info
8
@include docstyle.texi
Paul Eggert's avatar
Paul Eggert committed
9

Glenn Morris's avatar
Glenn Morris committed
10
@copying
Paul Eggert's avatar
Paul Eggert committed
11
Copyright @copyright{} 1995--1997, 2001--2017 Free Software Foundation, Inc.
Glenn Morris's avatar
Glenn Morris committed
12 13 14

@quotation
Permission is granted to copy, distribute and/or modify this document
15
under the terms of the GNU Free Documentation License, Version 1.3 or
Glenn Morris's avatar
Glenn Morris committed
16
any later version published by the Free Software Foundation; with no
17
Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'',
18 19
and with the Back-Cover Texts as in (a) below.  A copy of the license
is included in the section entitled ``GNU Free Documentation License''.
Glenn Morris's avatar
Glenn Morris committed
20

21
(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
22
modify this GNU manual.''
Glenn Morris's avatar
Glenn Morris committed
23 24 25
@end quotation
@end copying

26
@dircategory Emacs misc features
Glenn Morris's avatar
Glenn Morris committed
27
@direntry
Glenn Morris's avatar
Glenn Morris committed
28
* VIPER: (viper).               A VI-emulation mode for Emacs.
Glenn Morris's avatar
Glenn Morris committed
29 30 31 32 33 34 35
@end direntry

@finalout

@titlepage
@title Viper Is a Package for Emacs Rebels
@subtitle a Vi emulator for Emacs
36
@subtitle November 2008, Viper Version 3.11.2
Glenn Morris's avatar
Glenn Morris committed
37 38 39 40 41 42 43 44 45 46

@author Michael Kifer (Viper)
@author Aamod Sane (VIP 4.4)
@author Masahiko Sato (VIP 3.5)

@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

47 48
@contents

Glenn Morris's avatar
Glenn Morris committed
49
@ifnottex
50 51
@node Top
@top Viper
Glenn Morris's avatar
Glenn Morris committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

We believe that one or more of the following statements are adequate
descriptions of Viper:

@example
Viper Is a Package for Emacs Rebels;
it is a VI Plan for Emacs Rescue
and/or a venomous VI PERil.
@end example

Technically speaking, Viper is a Vi emulation package for Emacs.  It
implements all Vi and Ex commands, occasionally improving on them and
adding many new features.  It gives the user the best of both worlds: Vi
keystrokes for editing combined with the power of the Emacs environment.

Viper emulates Vi at several levels, from the one that closely follows Vi
conventions to the one that departs from many of them.  It has many
customizable options, which can be used to tailor Viper to the work habits
of various users.
This manual describes Viper, concentrating on the differences from Vi and
new features of Viper.

Viper, formerly known as VIP-19, was written by Michael Kifer.  It is based
on VIP version 3.5 by Masahiko Sato and VIP version 4.4 by Aamod Sane.
About 15% of the code still comes from those older packages.

78
Viper is intended to be usable without reading this manual; the defaults
Glenn Morris's avatar
Glenn Morris committed
79 80 81 82 83 84 85 86 87 88 89 90 91
are set to make Viper as close to Vi as possible.  At startup, Viper will
try to set the most appropriate default environment for you, based on
your familiarity with Emacs.  It will also tell you the basic GNU Emacs window
management commands to help you start immediately.

Although this manual explains how to customize Viper, some basic
familiarity with Emacs Lisp is a plus.

It is recommended that you read the Overview node.  The other nodes may
be visited as needed.

Comments and bug reports are welcome.
@code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
92
Please use the Ex command @kbd{:submitReport} for this purpose.
Glenn Morris's avatar
Glenn Morris committed
93

94
@insertcopying
Glenn Morris's avatar
Glenn Morris committed
95 96 97 98 99 100 101
@end ifnottex

@menu
* Overview::                    Read for a smoother start
* Improvements over Vi::        New features, Improvements
* Customization::               How to customize Viper
* Commands::                    Vi and Ex Commands
102 103
* GNU Free Documentation License:: The license for this documentation.
* Acknowledgments::
Glenn Morris's avatar
Glenn Morris committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
* Key Index::                   Index of Vi and Ex Commands
* Function Index::              Index of Viper Functions
* Variable Index::              Index of Viper Variables
* Package Index::               Index of Packages Mentioned in this Document
* Concept Index::               Vi, Ex and Emacs concepts
@end menu
@iftex
@unnumbered Introduction

We believe that one or more of the following statements are adequate
descriptions of Viper:

@example
Viper Is a Package for Emacs Rebels;
it is a VI Plan for Emacs Rescue
and/or a venomous VI PERil.
@end example

Viper is a Vi emulation package for Emacs.  Viper contains virtually all
of Vi and Ex functionality and much more.  It gives you the best of both
worlds: Vi keystrokes for editing combined with the GNU Emacs
environment.  Viper also fixes some common complaints with Vi commands.
This manual describes Viper, concentrating on the differences from Vi
and on the new features of Viper.

Viper was written by Michael Kifer.  It is based on VIP version 3.5 by
Masahiko Sato and VIP version 4.4 by Aamod Sane.  About 15% of the code
still comes from those older packages.

133 134
Viper is intended to be usable out of the box, without reading this manual;
the defaults are set to make Viper as close to Vi as possible.  At
Glenn Morris's avatar
Glenn Morris committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
startup, Viper will attempt to set the most appropriate default environment
for you, based on your familiarity with Emacs.  It will also tell you the
basic GNU Emacs window management commands to help you start immediately.

Although this manual explains how to customize Viper, some basic
familiarity with Emacs Lisp is a plus.

It is recommended that you read the chapter Overview.  The other chapters
will be useful for customization and advanced usage.

You should also learn to use the Info on-line hypertext manual system that
comes with Emacs.  This manual can be read as an Info file.  Try the command
@kbd{@key{ESC} x info} with vanilla Emacs sometime.

Comments and bug reports are welcome.
@code{kifer@@cs.stonybrook.edu} is the current address for Viper bug reports.
151
Please use the Ex command @kbd{:submitReport} for this purpose.
Glenn Morris's avatar
Glenn Morris committed
152 153 154

@end iftex

155
@node Overview
Glenn Morris's avatar
Glenn Morris committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
@chapter Overview of Viper

Viper is a Vi emulation on top of Emacs.  At the same time, Viper provides a
virtually unrestricted access to Emacs facilities.  Perfect compatibility
with Vi is possible but not desirable.  This chapter tells you about the
Emacs ideas that you should know about, how to use Viper within Emacs and
some incompatibilities.

This manual is written with the assumption that you are an experienced Vi
user who wants to switch to Emacs while retaining the ability to edit files
Vi style. Incredible as it might seem, there are experienced Emacs users
who use Viper as a backdoor into the superior (as every Vi user already knows)
world of Vi! These users are well familiar with Emacs bindings and prefer them
in some cases, especially in the Vi Insert state. John Hawkins
<jshawkin@@eecs.umich.edu> has provided a set of customizations, which
enables additional Emacs bindings under Viper.  These customizations can be
172 173
included in your @file{~/.emacs.d/viper} file and are found at the
following URL: @file{http://traeki.freeshell.org/files/viper-sample}.
Glenn Morris's avatar
Glenn Morris committed
174 175 176 177 178 179 180 181 182 183 184

@menu
* Emacs Preliminaries::         Basic concepts in Emacs.
* Loading Viper::               Loading and Preliminary Configuration.
* States in Viper::             Viper has four states orthogonal to Emacs
                                modes.
* The Minibuffer::              Command line in Emacs.
* Multiple Files in Viper::     True multiple file handling.
* Unimplemented Features::      That are unlikely to be implemented.
@end menu

185
@node Emacs Preliminaries
Glenn Morris's avatar
Glenn Morris committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
@section Emacs Preliminaries

@cindex buffer
@cindex point
@cindex mark
@cindex text
@cindex looking at
@cindex end (of buffer)
@cindex end (of line)
@cindex region

Emacs can edit several files at once.  A file in Emacs is placed in a
@dfn{buffer} that usually has the same name as the file.  Buffers are also used
for other purposes, such as shell interfaces, directory editing, etc.
@xref{Dired,,Directory Editor,emacs,The
201
GNU Emacs Manual}, for an example.
Glenn Morris's avatar
Glenn Morris committed
202 203 204 205 206

A buffer has a distinguished position called the @dfn{point}.
A @dfn{point} is always between 2 characters, and is @dfn{looking at}
the right hand character.  The cursor is positioned on the right hand
character.  Thus, when the @dfn{point} is looking at the end-of-line,
207
the cursor is on the end-of-line character, i.e., beyond the last
208
character on the line.  This is the default Emacs behavior.
Glenn Morris's avatar
Glenn Morris committed
209 210 211 212 213 214

The default settings of Viper try to mimic the behavior of Vi, preventing
the cursor from going beyond the last character on the line.  By using
Emacs commands directly (such as those bound to arrow keys), it is possible
to get the cursor beyond the end-of-line.  However, this won't (or
shouldn't) happen if you restrict yourself to standard Vi keys, unless you
215
modify the default editing style.  @xref{Customization}.
Glenn Morris's avatar
Glenn Morris committed
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235

In addition to the @dfn{point}, there is another distinguished buffer
position called the @dfn{mark}.  @xref{Mark,,Mark,emacs,The GNU Emacs
manual}, for more info on the mark.  The text between the @dfn{point} and
the @dfn{mark} is called the @dfn{region} of the buffer.  For the Viper
user, this simply means that in addition to the Vi textmarkers a--z, there
is another marker called @dfn{mark}.  This is similar to the unnamed Vi
marker used by the jump commands @kbd{``} and @kbd{''}, which move the
cursor to the position of the last absolute jump.  Viper provides access to
the region in most text manipulation commands as @kbd{r} and @kbd{R} suffix
to commands that operate on text regions, e.g., @kbd{dr} to delete region,
etc.

Furthermore, Viper lets Ex-style commands to work on the current region.
This is done by typing a digit argument before @kbd{:}.  For instance,
typing @kbd{1:} will prompt you with something like @emph{:123,135},
assuming that the current region starts at line 123 and ends at line
135.  There is no need to type the line numbers, since Viper inserts them
automatically in front of the Ex command.

236
@xref{Basics}, for more info.
Glenn Morris's avatar
Glenn Morris committed
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256

@cindex window
@cindex mode line
@cindex buffer information
@cindex Minibuffer
@cindex command line
@cindex buffer (modified)

Emacs divides the screen into tiled @dfn{windows}.  You can see the
contents of a buffer through the window associated with the buffer.  The
cursor of the screen is positioned on the character after @dfn{point}.
Every window has a @dfn{mode line} that displays information about the buffer.
You can change the format of the mode
line, but normally if you see @samp{**} at the beginning of a mode line it
means that the buffer is @dfn{modified}.  If you write out the contents of
a buffer to a file, then the buffer will become not modified.  Also if
you see @samp{%%} at the beginning of the mode line, it means that the file
associated with the buffer is write protected.  The mode line will also
show the buffer name and current major and minor modes (see below).
A special buffer called @dfn{Minibuffer} is displayed as the last line
257 258
in a minibuffer window.  The minibuffer window is used for command input
output.  Viper uses minibuffer window for @kbd{/} and @kbd{:}
259
commands.
Glenn Morris's avatar
Glenn Morris committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278

@cindex mode
@cindex keymap
@cindex local keymap
@cindex global keymap
@cindex major mode
@cindex minor mode

An Emacs buffer can have a @dfn{major mode} that customizes Emacs for
editing text of a particular sort by changing the functionality of the keys.
Keys are defined using a @dfn{keymap} that records the bindings between
keystrokes and
functions.  The @dfn{global keymap} is common to all the
buffers.  Additionally, each buffer has its @dfn{local keymap} that determines the
@dfn{mode} of the buffer.  If a function is bound to some key in the local
keymap then that function will be executed when you type the key.
If no function is bound to a key in the
local map, however, the function bound to the key in the global map
will be executed.  @xref{Major Modes,Major Modes,Major Modes,emacs,The
279
GNU Emacs Manual}, for more information.
Glenn Morris's avatar
Glenn Morris committed
280 281 282 283 284 285 286

A buffer can also have a @dfn{minor mode}.  Minor modes are options that
you can use or not.  A buffer in @code{text-mode} can have
@code{auto-fill-mode} as minor mode, which can be turned off or on at
any time.  In Emacs, a minor mode may have it own keymap,
which overrides the local keymap when the minor mode is turned on.  For
more information, @pxref{Minor Modes,Minor Modes,Minor Modes,emacs,The
287
GNU Emacs Manual}.
Glenn Morris's avatar
Glenn Morris committed
288 289 290 291 292 293 294 295 296

@cindex Viper as minor mode
@cindex Control keys
@cindex Meta key

Viper is implemented as a collection of minor modes.  Different minor modes
are involved when Viper emulates Vi command mode, Vi insert mode, etc.
You can also turn Viper on and off at any time while in Vi command mode.
@xref{States in Viper}, for
297
more information.
Glenn Morris's avatar
Glenn Morris committed
298 299

Emacs uses Control and Meta modifiers.  These are denoted as C and M,
300
e.g., @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}.  The Meta key is
Glenn Morris's avatar
Glenn Morris committed
301 302 303 304 305 306
usually located on each side of the Space bar; it is used in a manner
similar to the Control key, e.g., @kbd{M-x} means typing @kbd{x} while
holding the Meta key down.  For keyboards that do not have a Meta key,
@key{ESC} is used as Meta.  Thus @kbd{M-x} is typed as @kbd{@key{ESC}
x}.  Viper uses @key{ESC} to switch from Insert state to Vi state.  Therefore
Viper defines @kbd{C-\} as its Meta key in Vi state.  @xref{Vi State}, for
307
more info.
Glenn Morris's avatar
Glenn Morris committed
308 309 310 311 312

Emacs is structured as a Lisp interpreter around a C core.  Emacs keys
cause Lisp functions to be called.  It is possible to call these
functions directly, by typing @kbd{M-x function-name}.

313
@node Loading Viper
Glenn Morris's avatar
Glenn Morris committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
@section Loading Viper

The most common way to load it automatically is to include the following
lines (in the given order!):

@lisp
(setq viper-mode t)
(require 'viper)
@end lisp

@noindent
in your @file{~/.emacs} file.  The @file{.emacs} file is placed in your
home directory and it is be executed every time you invoke Emacs.  This is
the place where all general Emacs customization takes place.  Beginning with
version 20.0, Emacsen have an interactive interface, which simplifies the
job of customization significantly.

331
Viper also uses the file @file{~/.emacs.d/viper} for Viper-specific customization.
Glenn Morris's avatar
Glenn Morris committed
332 333 334 335 336 337
The location of Viper customization file can be changed by setting the
variable @code{viper-custom-file-name} in @file{.emacs} @emph{prior} to loading
Viper.

The latest versions of Emacs have an interactive customization facility,
which allows you to (mostly) bypass the use of the @file{.emacs} and
338
@code{viper-custom-file-name} files. You can reach this customization
Glenn Morris's avatar
Glenn Morris committed
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
facility from within Viper's VI state by executing the Ex command
@kbd{:customize}.

Once invoked, Viper will arrange to bring up Emacs buffers in Vi state
whenever this makes sense.
@xref{Packages that Change Keymaps}, to find out when forcing Vi command state
on a buffer may be counter-productive.

Even if your @file{.emacs} file does not invoke Viper automatically,
you can still load Viper and enter the Vi command state by typing the
following from within Emacs:

@lisp
M-x viper-mode
@end lisp

When Emacs first comes up, if you have not specified a file on the
356
command line, it will show the @file{*scratch*} buffer, in the
Glenn Morris's avatar
Glenn Morris committed
357 358 359 360
@samp{Lisp Interaction} mode.  After you invoke Viper, you can start
editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands.
(@xref{File and Buffer Handling}, for more information on @kbd{v} and other
new commands that, in many cases, are more convenient than @kbd{:e},
361
@kbd{:vi}, and similar old-style Vi commands.)
Glenn Morris's avatar
Glenn Morris committed
362 363 364 365 366 367

Finally, if at some point you would want to de-Viperize your running
copy of Emacs after Viper has been loaded, the command @kbd{M-x
viper-go-away} will do it for you.  The function @code{toggle-viper-mode}
toggles Viperization of Emacs on and off.

368
@node States in Viper
Glenn Morris's avatar
Glenn Morris committed
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
@section States in Viper

@kindex @kbd{C-z}
@kindex @key{ESC}
@kindex @kbd{i}
@cindex Emacs state
@cindex Vi state
@cindex Insert state
@cindex Replace state
@cindex Ex commands
@findex @code{viper-go-away}
@findex @code{toggle-viper-mode}

Viper has four states, Emacs, Vi, Insert, and Replace.

@table @samp
@item Emacs state
This is the state plain vanilla Emacs is normally in.  After you have loaded
Viper, @kbd{C-z} will normally take you to Vi command state.  Another
@kbd{C-z} will take you back to Emacs state.  This toggle key can be
changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to
390
change to Vi state.
Glenn Morris's avatar
Glenn Morris committed
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427


For users who chose to set their user level to 1 at Viper setup time,
switching to Emacs state is deliberately made harder in order to not
confuse the novice user.  In this case, @kbd{C-z} will either iconify Emacs
(if Emacs runs as an application under X) or it will stop Emacs (if
Emacs runs on a dumb terminal or in an Xterm window).

@item Vi state
This is the Vi command mode.  Any of the Vi commands, such as @kbd{i, o, a},
@dots{}, will take you to Insert state.  All Vi commands may
be used in this mode.  Most Ex commands can also be used.
For a full list of Ex commands supported by Viper, type
@kbd{:} and then @key{TAB}.  To get help on any issue, including the Ex
commands, type @kbd{:help}.  This will invoke Viper Info
(if it is installed).  Then typing @kbd{i} will prompt you for a topic to
search in the index.  Note: to search for Ex commands in the index, you
should start them with a @kbd{:}, e.g., @kbd{:WW}.

In Viper, Ex commands can be made to work on the current Emacs region.
This is done by typing a digit argument before @kbd{:}.
For instance, typing @kbd{1:} will prompt you with something like
@emph{:123,135}, assuming that the current region starts at line 123 and
ends at line 135.  There is no need to type the line numbers, since Viper
inserts them automatically in front of the Ex command.

@item Insert state
Insert state is the Vi insertion mode.  @key{ESC} will take you back to
Vi state.  Insert state editing can be done, including auto-indentation.  By
default, Viper disables Emacs key bindings in Insert state.

@item Replace state
Commands like @kbd{cw} invoke the Replace state.  When you cross the
boundary of a replacement region (usually designated via a @samp{$} sign),
it will automatically change to Insert state.  You do not have to worry
about it.  The key bindings remain practically the same as in Insert
state.  If you type @key{ESC}, Viper will switch to Vi command mode, terminating the
428
replacement state.
Glenn Morris's avatar
Glenn Morris committed
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
@end table

@cindex mode line

The modes are indicated on the @dfn{mode line} as <E>, <I>, <V>, and <R>,
so that the multiple modes do not confuse you.  Most of your editing can be
done in Vi and Insert states.  Viper will try to make all new buffers be in Vi
state, but sometimes they may come up in Emacs state.  @kbd{C-z}
will take you to Vi state in such a case.  In some major modes, like Dired,
Info, Gnus, etc., you should not switch to Vi state (and Viper will not
attempt to do so) because these modes are not intended for text editing and
many of the Vi keys have special meaning there.  If you plan to read news,
browse directories, read mail, etc., from Emacs (which you should start
doing soon!), you should learn about the meaning of the various keys in
those special modes (typing @kbd{C-h m} in a buffer provides
help with key bindings for the major mode of that buffer).

446
If you switch to Vi in Dired or similar modes, no harm is done.  It is just
Glenn Morris's avatar
Glenn Morris committed
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
that the special key bindings provided by those modes will be temporarily
overshadowed by Viper's bindings.  Switching back to Viper's Emacs state
will revive the environment provided by the current major mode.

States in Viper are orthogonal to Emacs major modes, such as C mode or Dired
mode.  You can turn Viper on and off for any Emacs state.  When Viper is turned
on, Vi state can be used to move around.  In Insert state, the bindings for
these modes can be accessed.  For beginners (users at Viper levels 1 and 2),
these bindings are suppressed in Insert state, so that new users are not
confused by the Emacs states.  Note that unless you allow Emacs bindings in
Insert state, you cannot do many interesting things, like language
sensitive editing.  For the novice user (at Viper level 1), all major mode
bindings are turned off in Vi state as well.  This includes the bindings for
key sequences that start with @kbd{C-c}, which practically means that all
major mode bindings are unsupported.  @xref{Customization}, to find out how
to allow Emacs keys in Insert state.

@menu
* Emacs State::         This is the state you should learn more about when
                        you get up to speed with Viper.
* Vi State::            Vi commands are executed in this state.
* Insert State::        You can enter text, and also can do sophisticated
                        editing if you know enough Emacs commands.
* Replace State::       Like Insert mode, but it is invoked via the
                        replacement commands, such as cw, C, R, etc.
@end menu

474
@node Emacs State
Glenn Morris's avatar
Glenn Morris committed
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
@subsection Emacs State

@kindex @kbd{C-z}
@cindex Emacs state


You will be in this mode only by accident (hopefully).  This is the state
Emacs is normally in (imagine!!).  Now leave it as soon as possible by
typing @kbd{C-z}.  Then you will be in Vi state (sigh of relief) :-).

Emacs state is actually a Viperism to denote all the major and minor modes
(@pxref{Emacs Preliminaries}) other than Viper that Emacs can be in.  Emacs
can have several modes, such as C mode for editing C programs, LaTeX mode
for editing LaTeX documents, Dired for directory editing, etc.  These are
major modes, each with a different set of key-bindings.  Viper states are
orthogonal to these Emacs major modes.  The presence of these language
sensitive and other modes is a major win over Vi.  @xref{Improvements over
492
Vi}, for more.
Glenn Morris's avatar
Glenn Morris committed
493 494 495 496 497 498 499 500 501 502 503 504 505

The bindings for these modes can be made available in the Viper Insert state
as well as in Emacs state.  Unless you specify your user level as 1 (a
novice), all major mode key sequences that start with @kbd{C-x} and
@kbd{C-c} are also available in Vi state.  This is important because major
modes designed for editing files, such as cc-mode or latex-mode, use key
sequences that begin with @kbd{C-x} and @kbd{C-c}.

There is also a key that lets you temporarily escape to Vi command state
from the Insert state: typing @kbd{C-z} will let you execute a
single Vi command while staying in Viper's Insert state.


506
@node Vi State
Glenn Morris's avatar
Glenn Morris committed
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612
@subsection Vi State

@cindex Vi state

This is the Vi command mode.  When Viper is in Vi state, you will see the sign
<V> in the mode line.  Most keys will work as in Vi.  The notable
exceptions are:

@table @kbd
@item C-x
@kindex @kbd{C-x}
@kbd{C-x} is used to invoke Emacs commands, mainly those that do window
management.  @kbd{C-x 2} will split a window, @kbd{C-x 0} will close a
window.  @kbd{C-x 1} will close all other windows.  @kbd{C-xb} is used to
switch buffers in a window, and @kbd{C-xo} to move through windows.
These are about the only necessary keystrokes.
For the rest, see the GNU Emacs Manual.

@item C-c
@kindex @kbd{C-c}
For user levels 2 and higher, this key serves as a prefix key for the key
sequences used by various major modes.  For users at Viper level 1, @kbd{C-c}
simply beeps.

@item C-g and C-]
@kindex @kbd{C-g}
@kindex @kbd{C-]}

These are the Emacs @samp{quit} keys.
There will be cases where you will have to
use @kbd{C-g} to quit.  Similarly, @kbd{C-]} is used to exit
@samp{Recursive Edits} in Emacs for which there is no comparable Vi
functionality and no key-binding.  Recursive edits are indicated by
@samp{[]} brackets framing the modes on the mode line.
@xref{Recursive Edit,Recursive
Edit,Recursive Edit,emacs,The GNU Emacs Manual}.
At user level 1, @kbd{C-g} is bound to @code{viper-info-on-file}
function instead.
@item C-\
@kindex @kbd{C-\}
@cindex Meta key

Viper uses @key{ESC} as a switch between Insert and Vi states.  Emacs uses
@key{ESC} for Meta.  The Meta key is very important in Emacs since many
functions are accessible only via that key as @kbd{M-x function-name}.
Therefore, we need to simulate it somehow.  In Viper's Vi, Insert, and
Replace states, the meta key is set to be @kbd{C-\}.  Thus, to get
@kbd{M-x}, you should type @kbd{C-\ x} (if the keyboard has no Meta key,
which is rare these days).
This works both in the Vi command state and in the Insert and Replace
states.  In Vi command state, you can also use @kbd{\ @key{ESC}} as the
meta key.

Note: Emacs binds @kbd{C-\} to a function that offers to change the
keyboard input method in the multilingual environment.  Viper overrides this
binding.  However, it is still possible to switch the input method by typing
@kbd{\ C-\} in the Vi command state and @kbd{C-z \ C-\} in the Insert state.
Or you can use the MULE menu in the menubar.
@end table
@noindent
Other differences are mostly improvements.  The ones you should know
about are:

@table @samp
@item Undo
@kindex @kbd{u}
@kbd{u} will undo.  Undo can be repeated by the @kbd{.} key.  Undo itself
can be undone.  Another @kbd{u} will change the direction.  The presence
of repeatable undo means that @kbd{U}, undoing lines, is not very
important.  Therefore, @kbd{U} also calls @code{viper-undo}.
@cindex multiple undo
@cindex undo


@item Counts
Most commands, @kbd{~}, @kbd{[[}, @kbd{p}, @kbd{/}, @dots{}, etc., take counts.

@comment ]] Just to balance parens
@item Regexps
Viper uses Emacs Regular Expressions for searches.  These are a superset of
Vi regular
expressions, excepting the change-of-case escapes @samp{\u}, @samp{\L},
@dots{}, etc.  @xref{Regexps,,Syntax of Regular Expressions,emacs,The
GNU Emacs Manual}, for details.
Files specified to @kbd{:e} use @code{csh} regular expressions
(globbing, wildcards, what have you).
However, the function @code{viper-toggle-search-style}, bound to @kbd{C-c /},
lets the user switch from search with regular expressions to plain vanilla
search and vice versa.  It also lets one switch from case-sensitive search
to case-insensitive and back.
@xref{Viper Specials}, for more details.
@cindex regular expressions
@cindex vanilla search
@cindex case-sensitive search
@cindex case-insensitive search
@kindex @kbd{C-c /}

@item Ex commands
@cindex Ex commands
The current working directory of a buffer is automatically inserted in the
minibuffer if you type @kbd{:e} then space.  Absolute filenames are
required less often in Viper.  For file names, Emacs uses a convention that
is slightly different from other programs.  It is designed to minimize the
need for deleting file names that Emacs provides in its prompts.  (This is
usually convenient, but occasionally the prompt may suggest a wrong file
name for you.)  If you see a prompt @kbd{/usr/foo/} and you wish to edit the
613 614
file @kbd{~/.file}, you don't have to erase the prompt.  Instead, simply
continue typing what you need.  Emacs will interpret @kbd{/usr/foo/~/.file}
Glenn Morris's avatar
Glenn Morris committed
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
correctly.  Similarly, if the prompt is @kbd{~/foo/} and you need to get to
@kbd{/bar/file}, keep typing.  Emacs interprets @kbd{~/foo//bar/} as
@kbd{/bar/file}, since when it sees @samp{//}, it understands that
@kbd{~/foo/} is to be discarded.

The command @kbd{:cd} will change the default directory for the
current buffer.  The command @kbd{:e} will interpret the
filename argument in @code{csh}.  @xref{Customization}, if you
want to change the default shell.
The command @kbd{:next} takes counts from
@kbd{:args}, so that @kbd{:rew} is obsolete.  Also, @kbd{:args} will show only
the invisible files (i.e., those that are not currently seen in Emacs
windows).

When applicable, Ex commands support file completion and history.  This
means that by typing a partial file name and then @key{TAB}, Emacs will try
to complete the name or it will offer a menu of possible completions.
This works similarly to Tcsh and extends the behavior of Csh.  While Emacs
is waiting for a file name, you can type @kbd{M-p} to get the previous file
name you typed.  Repeatedly typing @kbd{M-p} and @kbd{M-n} will let you
browse through the file history.

Like file names, partially typed Ex commands can be completed by typing
@key{TAB}, and Viper keeps the history of Ex commands.  After typing
@kbd{:}, you can browse through the previously entered Ex commands by
typing @kbd{M-p} and @kbd{M-n}.  Viper tries to rationalize when it puts Ex
commands on the history list.  For instance, if you typed @kbd{:w!@: foo},
only @kbd{:w!} will be placed on the history list.  This is because the
last history element is the default that can be invoked simply by typing
@kbd{: @key{RET}}.  If @kbd{:w!@: foo} were placed on the list, it would be all to
easy to override valuable data in another file.  Reconstructing the full
command, @kbd{:w!@: foo}, from the history is still not that hard, since Viper
has a separate history for file names.  By typing @kbd{: M-p}, you will get
648
@kbd{:w!} in the minibuffer.  Then, repeated @kbd{M-p} will get you through
Glenn Morris's avatar
Glenn Morris committed
649 650 651 652 653 654 655 656
the file history, inserting one file name after another.

In contrast to @kbd{:w!@: foo}, if the command were @kbd{:r foo}, the entire
command will appear in the history list.  This is because having @kbd{:r}
alone as a default is meaningless, since this command requires a file
argument.
@end table
@noindent
657 658
As in Vi, Viper's destructive commands can be re-executed by typing
a period (@kbd{.}).
Glenn Morris's avatar
Glenn Morris committed
659 660 661
However, in addition, Viper keeps track of the history of such commands.  This
history can be perused by typing @kbd{C-c M-p} and @kbd{C-c M-n}.
Having found the appropriate command, it can be then executed by typing
662
a period.
Glenn Morris's avatar
Glenn Morris committed
663 664
@xref{Improvements over Vi}, for more information.

665
@node Insert State
Glenn Morris's avatar
Glenn Morris committed
666 667 668 669 670 671 672 673 674 675
@subsection Insert State

@cindex Insert state

To avoid confusing the beginner (at Viper level 1 and 2), Viper makes only the
standard Vi keys available in Insert state.  The implication is that
Emacs major modes cannot be used in Insert state.
It is strongly recommended that as soon as you are comfortable, make the
Emacs state bindings visible (by changing your user level to 3 or higher).
@xref{Customization},
676
to see how to do this.
Glenn Morris's avatar
Glenn Morris committed
677 678 679 680 681 682

Once this is done, it is possible to do quite a bit of editing in
Insert state.  For instance, Emacs has a @dfn{yank} command, @kbd{C-y},
which is similar to Vi's @kbd{p}.  However, unlike @kbd{p}, @kbd{C-y} can be
used in Insert state of Viper.  Emacs also has a kill ring where it keeps
pieces of text you deleted while editing buffers.  The command @kbd{M-y} is
683
used to delete the text previously put back by Emacs's @kbd{C-y} or by Vi's
Glenn Morris's avatar
Glenn Morris committed
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
@kbd{p} command and reinsert text that was placed on the kill-ring earlier.

This works both in Vi and Insert states.
In Vi state, @kbd{M-y} is a much better alternative to the usual Vi's way
of recovering the 10 previously deleted chunks of text.  In Insert state,
you can
use this as follows.  Suppose you deleted a piece of text and now you need
to re-insert it while editing in Insert mode.  The key @kbd{C-y} will put
back the most recently deleted chunk.  If this is not what you want, type
@kbd{M-y} repeatedly and, hopefully, you will find the chunk you want.

Finally, in Insert and Replace states, Viper provides the history of
pieces of text inserted in previous insert or replace commands.  These
strings of text can be recovered by repeatedly typing @kbd{C-c M-p} or
@kbd{C-c M-n} while in Insert or Replace state.  (This feature is disabled
in the minibuffer: the above keys are usually bound to other histories,
which are more appropriate in the minibuffer.)


@cindex Meta key

You can call Meta functions from Insert state.  As in Vi state, the Meta key
is @kbd{C-\}.  Thus @kbd{M-x} is typed as @kbd{C-\ x}.

Other Emacs commands that are useful in Insert state are @kbd{C-e}
and @kbd{C-a}, which move the cursor to the end and the beginning of the
current line, respectively.  You can also use @kbd{M-f} and @kbd{M-b},
which move the cursor forward (or backward) one word.
If your display has a Meta key, these functions are invoked by holding the
Meta key and then typing @kbd{f} and @kbd{b}, respectively.  On displays
without the Meta key, these functions are invoked by typing
@kbd{C-\ f} and @kbd{C-\ b} (@kbd{C-\} simulates the Meta key in Insert
state, as explained above).

The key @kbd{C-z} is sometimes also useful in Insert state: it allows you
to execute a single command in Vi state without leaving the Insert state!
For instance, @kbd{C-z d2w} will delete the next two words without leaving
the Insert state.

When Viper is in Insert state, you will see <I> in the mode line.

725
@node Replace State
Glenn Morris's avatar
Glenn Morris committed
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
@subsection Replace State

@cindex Replace state

This state is entered through Vi replacement commands, such as @kbd{C},
@kbd{cw}, etc., or by typing @kbd{R}.  In Replace state, Viper puts <R> in
the mode line to let you know which state is in effect.  If Replace state is
entered through @kbd{R}, Viper stays in that state until the user hits
@key{ESC}.  If this state is entered via the other replacement commands,
then Replace state is in effect until you hit @key{ESC} or until you cross
the rightmost boundary of the replacement region.  In the latter case, Viper
changes its state from Replace to Insert (which you will notice by the
change in the mode line).

Since Viper runs under Emacs, it is possible to switch between buffers
while in Replace state.  You can also move the cursor using the arrow keys
(even on dumb terminals!)@: and the mouse.  Because of this freedom (which is
unattainable in regular Vi), it is possible to take the cursor outside the
replacement region.  (This may be necessary for several reasons, including
the need to enable text selection and region-setting with the mouse.)

The issue then arises as to what to do when the user
hits the @key{ESC} key.  In Vi, this would cause the text between cursor and
the end of the replacement region to be deleted.  But what if, as is
possible in Viper, the cursor is not inside the replacement region?

To solve the problem, Viper keeps track of the last cursor position while it
was still inside the replacement region.  So, in the above situation, Viper
would delete text between this position and the end of the replacement
region.

757
@node The Minibuffer
Glenn Morris's avatar
Glenn Morris committed
758 759 760 761
@section The Minibuffer

@cindex Minibuffer

762
The minibuffer is where commands are entered in.  Editing can be done
Glenn Morris's avatar
Glenn Morris committed
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
by commands from Insert state, namely:

@table @kbd
@item C-h
Backspace
@item C-w
Delete Word
@item C-u
Erase line
@item C-v
Quote the following character
@item @key{RET}
Execute command
@item C-g and C-]
Emacs quit and abort keys.  These may be necessary.  @xref{Vi State}, for an
explanation.
@item M-p and M-n
These keys are bound to functions that peruse minibuffer history.  The
precise history to be perused depends on the context.  It may be the history
of search strings, Ex commands, file names, etc.
783 784 785 786 787
@item C-s
If the minibuffer is entered via the Viper search commands @kbd{/} or
@kbd{?}, then this key inserts the last search string used by the
Emacs incremental search command
(which is bound to @kbd{C-s} everywhere except in this case).
Glenn Morris's avatar
Glenn Morris committed
788 789
@end table

790 791
Most of the Emacs keys are functional in the minibuffer.  While in the
minibuffer, Viper tries to make editing resemble Vi's behavior when the
Glenn Morris's avatar
Glenn Morris committed
792
latter is waiting for the user to type an Ex command.  In particular, you
793
can use the regular Vi commands to edit the minibuffer.  You can switch
Glenn Morris's avatar
Glenn Morris committed
794
between the Vi state and Insert state at will, and even use the replace mode.
795
Initially, the minibuffer comes up in Insert state.
Glenn Morris's avatar
Glenn Morris committed
796

797
Some users prefer plain Emacs bindings in the minibuffer.  To this end, set
798 799
@code{viper-vi-style-in-minibuffer} to @code{nil} in
your Viper customization file.  @xref{Customization}, to learn how to do this.
Glenn Morris's avatar
Glenn Morris committed
800

801 802
When the minibuffer changes Viper states, you will notice that the appearance
of the text there changes as well.  This is useful because the minibuffer
Glenn Morris's avatar
Glenn Morris committed
803
has no mode line to tell which Vi state it is in.
804
The appearance of the text in the minibuffer can be changed.
Glenn Morris's avatar
Glenn Morris committed
805 806
@xref{Viper Specials}, for more details.

807
@node Multiple Files in Viper
Glenn Morris's avatar
Glenn Morris committed
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825
@section Multiple Files in Viper

@cindex multiple files
@cindex managing multiple files

Viper can edit multiple files.  This means, for example that you never need
to suffer through @code{No write since last change} errors.
Some Viper elements are common over all the files.

@table @samp
@item Textmarkers
@cindex markers
@cindex textmarkers
Textmarkers remember @emph{files and positions}.
If you set marker @samp{a} in
file @file{foo}, start editing file @file{bar} and type @kbd{'a}, then
@emph{YOU WILL SWITCH TO FILE @file{foo}}.  You can see the contents of a
textmarker using the Viper command @kbd{[<a-z>} where <a-z> are the
826
textmarkers, e.g., @kbd{[a} to view marker @samp{a} .
Glenn Morris's avatar
Glenn Morris committed
827 828 829 830 831
@item Repeated Commands
Command repetitions are common over files.  Typing @kbd{!!} will repeat the
last @kbd{!} command whichever file it was issued from.
Typing @kbd{.} will repeat the last command from any file, and
searches will repeat the last search.  Ex commands can be repeated by typing
832
@kbd{: @key{RET}}.
Glenn Morris's avatar
Glenn Morris committed
833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858
Note: in some rare cases, that @kbd{: @key{RET}} may do something dangerous.
However, usually its effect can be undone by typing @kbd{u}.
@item Registers
@cindex registers
Registers are common to files.  Also, text yanked with @kbd{y} can be
put back (@kbd{p}) into any file.  The Viper command @kbd{]<a-z>}, where <a-z> are
the registers, can be used to look at the contents of a register, e.g.,
type @kbd{]a} to view register @samp{a}.

There is one difference in text deletion that you should be
aware of.  This difference comes from Emacs and was adopted in Viper
because we find it very useful.  In Vi, if you delete a line, say, and then
another line, these two deletions are separated and are put back
separately if you use the @samp{p} command.  In Emacs (and Viper), successive
series of deletions that are @emph{not interrupted} by other commands are
lumped together, so the deleted text gets accumulated and can be put back
as one chunk.  If you want to break a sequence of deletions so that the
newly deleted text could be put back separately from the previously deleted
text, you should perform a non-deleting action, e.g., move the cursor one
character in any direction.
@item Absolute Filenames
@cindex absolute file names
The current directory name for a file is automatically prepended to the
file name in any
@kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a
current directory).
859
This directory is inserted in the minibuffer once you type space after
Glenn Morris's avatar
Glenn Morris committed
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879
@kbd{:e, r}, etc.  Viper also supports completion of file names and Ex
commands (@key{TAB}), and it keeps track of
command and file history (@kbd{M-p}, @kbd{M-n}).
Absolute filenames are required less
often in Viper.

You should be aware that Emacs interprets @kbd{/foo/bar//bla} as
@kbd{/bla} and @kbd{/foo/~/bar} as @kbd{~/bar}.  This is designed to
minimize the need for erasing file names that Emacs suggests in its
prompts, if a suggested file name is not what you wanted.

The command @kbd{:cd} will change the default directory for the
current Emacs buffer.  The Ex command @kbd{:e} will interpret the
filename argument in @samp{csh}, by default.  @xref{Customization}, if you
want to change this.
@end table

@noindent
Currently undisplayed files can be listed using the @kbd{:ar} command.  The
command @kbd{:n} can be given counts from the @kbd{:ar} list to switch to
880 881
other files.  For example, use @samp{:n3} to move to the third file in
that list.
Glenn Morris's avatar
Glenn Morris committed
882

883
@node Unimplemented Features
Glenn Morris's avatar
Glenn Morris committed
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
@section Unimplemented Features

Unimplemented features include:

@itemize @bullet
@item
@kbd{:ab} and @kbd{:una} are not implemented, since
@kbd{:ab} is considered obsolete, since Emacs has much
more powerful facilities for defining abbreviations.
@item
@kbd{:set option?} is not implemented.  The current
@kbd{:set} can also be used to set Emacs variables.
@item
@kbd{:se list} requires modification of the display code for Emacs, so
it is not implemented.
A useful alternative is @code{cat -t -e file}.  Unfortunately, it cannot
be used directly inside Emacs, since Emacs will obdurately change @samp{^I}
901
back to normal tabs.
Glenn Morris's avatar
Glenn Morris committed
902 903
@end itemize

904
@node Improvements over Vi
Glenn Morris's avatar
Glenn Morris committed
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
@chapter Improvements over Vi

Some common problems with Vi and Ex have been solved in Viper.  This
includes better implementation of existing commands, new commands, and
the facilities provided by Emacs.

@menu
* Basics::                  Basic Viper differences, Multi-file effects.
* Undo and Backups::        Multiple undo, auto-save, backups and changes
* History::                 History for Ex and Vi commands.
* Macros and Registers::    Keyboard Macros (extended ".")@: @@reg execution.
* Completion::              Filename and Command Completion for Ex.
* Improved Search::         Incremental Search and Buffer Content Search.
* Abbreviation Facilities:: Normal Abbrevs, Templates, and Dynamic Abbrevs.
* Movement and Markers::    Screen Editor movements, viewing textmarkers.
* New Commands::            Commands that do not exist in Vi.
* Useful Packages::         A Sampling of some Emacs packages, and things
                            you should know about.
@end menu

925
@node Basics
Glenn Morris's avatar
Glenn Morris committed
926 927 928 929 930 931
@section Basics

The Vi command set is based on the idea of combining motion commands
with other commands.  The motion command is used as a text region
specifier for other commands.
We classify motion commands into @dfn{point commands} and
932
@dfn{line commands}.
Glenn Morris's avatar
Glenn Morris committed
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992

@cindex point commands

The point commands are:

@quotation
@kbd{h}, @kbd{l}, @kbd{0},  @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B},
@kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f},
@kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^}
@end quotation

@cindex line commands

The line commands are:

@quotation
@kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{},
@kbd{@}}, @kbd{G}, @kbd{'},  @kbd{[[}, @kbd{]]}, @kbd{[]}
@end quotation

@cindex region
@cindex region specification
@cindex expanding (region)
@cindex describing regions
@cindex movement commands

@noindent
If a point command is given as an argument to a modifying command, the
region determined by the point command will be affected by the modifying
command.  On the other hand, if a line command is given as an argument to a
modifying command, the region determined by the line command will be
enlarged so that it will become the smallest region properly containing the
region and consisting of whole lines (we call this process @dfn{expanding
the region}), and then the enlarged region will be affected by the modifying
command.
Text Deletion Commands (@pxref{Deleting Text}), Change commands
(@pxref{Changing Text}), even Shell Commands (@pxref{Shell Commands})
use these commands to describe a region of text to operate on.
Thus, type @kbd{dw} to delete a word, @kbd{>@}} to shift a paragraph, or
@kbd{!'afmt} to format a region from @samp{point} to textmarker
@samp{a}.

@cindex r and R region specifiers

Viper adds the region specifiers @samp{r} and @samp{R}.  Emacs has a
special marker called @dfn{mark}.  The text-area between the current cursor
position @dfn{point} and the @dfn{mark} is called the @dfn{region}.
@samp{r} specifies the raw region and @samp{R} is the expanded region
(i.e., the minimal contiguous chunk of full lines that contains the raw
region).
@kbd{dr} will now delete the region, @kbd{>r} will shift it, etc.
@kbd{r,R} are not motion commands, however.  The special mark is set by
@kbd{m.} and other commands.  @xref{Marking}, for more info.

Viper also adds counts to most commands for which it would make sense.

In the Overview chapter, some Multiple File issues were discussed
(@pxref{Multiple Files in Viper}).  In addition to the files, Emacs has
buffers.  These can be seen in the @kbd{:args} list and switched using
@kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or
993 994
specify @code{(setq ex-cycle-through-non-files t)} in your
Viper customization file.  @xref{Customization}, for details.
Glenn Morris's avatar
Glenn Morris committed
995

996
@node Undo and Backups
Glenn Morris's avatar
Glenn Morris committed
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
@section Undo and Backups

@cindex undo

Viper provides multiple undo.  The number of undo's and the size is limited
by the machine.  The Viper command @kbd{u} does an undo.  Undo can be
repeated by typing @kbd{.} (a period).  Another @kbd{u} will undo the undo,
and further
@kbd{.} will repeat it.  Typing @kbd{u} does the first undo, and changes the
direction.

@cindex backup files
@cindex auto save

Since the undo size is limited, Viper can create backup files and
auto-save files.  It will normally do this automatically.  It is possible
to have numbered backups, etc.  For details, @pxref{Backup,,Backup and
1014
Auto-Save,emacs,The GNU Emacs Manual}.
Glenn Morris's avatar
Glenn Morris committed
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031

@comment [ balance parens
@cindex viewing registers and markers
@cindex registers
@cindex markers
@cindex textmarkers

The results of the 9 previous changes are available in the 9 numeric
registers, as in Vi.  The extra goody is the ability to @emph{view} these
registers, in addition to being able to access them through @kbd{p} and
@kbd{M-y} (@xref{Insert State}, for details.)
The Viper command @kbd{] register} will display the contents of any
register, numeric or alphabetical.  The related command @kbd{[ textmarker}
will show the text around the textmarker.  @samp{register} and @samp{textmarker}
can be any letters from a through z.
@comment ] balance parens

1032
@node History
Glenn Morris's avatar
Glenn Morris committed
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043
@section History

@cindex history
@cindex Minibuffer

History is provided for Ex commands, Vi searches, file names, pieces of
text inserted in earlier commands that use Insert or Replace state, and for
destructive commands in Vi state.  These are
useful for fixing those small typos that screw up searches and @kbd{:s},
and for eliminating routine associated with repeated typing of file names
or pieces of text that need to be inserted frequently.
1044
At the @kbd{:} or @kbd{/} prompts in the minibuffer, you can do the following:
Glenn Morris's avatar
Glenn Morris committed
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070

@table @kbd
@item M-p and M-n
To move to previous and next history items.  This causes the history
items to appear on the command line, where you can edit them, or
simply type Return to execute.
@item M-r and M-s
To search backward and forward through the history.
@item @key{RET}
Type @key{RET} to accept a default (which is displayed in the prompt).
@end table

The history of insertions  can be perused by
typing @kbd{C-c M-p} and @kbd{C-c M-n} while in Insert or Replace state.
The history of destructive Vi commands can be perused via the same keys
when Viper is in Vi state.  @xref{Viper Specials}, for details.

All Ex commands have a file history.  For instance, typing @kbd{:e}, space
and then @kbd{M-p} will bring up the name of the previously typed file
name.  Repeatedly typing @kbd{M-p}, @kbd{M-n}, etc., will let you browse
through the file history.

Similarly, commands that have to do with switching buffers
have a buffer history, and commands that expect strings or regular
expressions keep a history on those items.

1071
@node Macros and Registers
Glenn Morris's avatar
Glenn Morris committed
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086
@section Macros and Registers

@cindex keyboard macros
@cindex macros
@cindex registers
@cindex register execution

Viper facilitates the use of Emacs-style keyboard macros.  @kbd{@@#} will
start a macro definition.  As you type, the commands will be executed, and
remembered (This is called ``learn mode'' in some editors.)
@kbd{@@register} will complete the macro, putting it into @samp{register},
where @samp{register} is any character from @samp{a} through @samp{z}.  Then
you can execute this macro using @kbd{@@register}.  It is, of course,
possible to yank some text into a register and execute it using
@kbd{@@register}.  Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@C-j} will
1087
execute the last macro that was executed using @kbd{@@register}.
Glenn Morris's avatar
Glenn Morris committed
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108

Viper will automatically lowercase the register, so that pressing the
@kbd{SHIFT} key for @kbd{@@} will not create problems.  This is for
@kbd{@@} macros and @kbd{"p} @emph{only}.  In the case of @kbd{y},
@kbd{"Ayy} will append to @emph{register a}.  For @kbd{[,],',`}, it
is an error to use a Uppercase register name.

@comment [ balance parens
@cindex viewing registers and markers

The contents of a register can be seen by @kbd{]register}.  (@kbd{[textmarker}
will show the contents of a textmarker).
@comment ] balance parens

@cindex last keyboard macro

The last keyboard macro can also be executed using
@kbd{*}, and it can be yanked into a register using @kbd{@@!register}.
This is useful for Emacs style keyboard macros defined using @kbd{C-x(}
and @kbd{C-x)}.  Emacs keyboard macros have more capabilities.
@xref{Keyboard Macros,,Keyboard Macros,emacs, The GNU Emacs Manual}, for
1109
details.
Glenn Morris's avatar
Glenn Morris committed
1110 1111 1112 1113 1114 1115 1116 1117

Keyboard Macros allow an interesting form of Query-Replace:
@kbd{/pattern} or @kbd{n} to go to the next pattern (the query), followed by a
Keyboard Macro execution @kbd{@@@@} (the replace).

Viper also provides Vi-style macros.  @xref{Vi Macros}, for details.


1118
@node Completion
Glenn Morris's avatar
Glenn Morris committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
@section Completion

@cindex completion

Completion is done when you type @key{TAB}.  The Emacs completer does not
grok wildcards in file names.  Once you type a wildcard, the completer will
no longer work for that file name.  Remember that Emacs interprets a file name
of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as
@kbd{~/bar}.

1129
@node Improved Search
Glenn Morris's avatar
Glenn Morris committed
1130 1131 1132 1133 1134 1135
@section Improved Search

@cindex buffer search
@cindex word search

Viper provides buffer search, the ability to search the buffer for a region
1136 1137
under the cursor.  You have to turn this on in your Viper customization file
either by calling
Glenn Morris's avatar
Glenn Morris committed
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165

@example
(viper-buffer-search-enable)
@end example

@noindent
or by setting @code{viper-buffer-search-char} to, say, @kbd{f3}:
@example
(setq viper-buffer-search-char ?g)
@end example

@noindent
If the user calls @code{viper-buffer-search-enable} explicitly (the first
method), then @code{viper-buffer-search-char} will be set to @kbd{g}.
Regardless of how this feature is enabled, the key
@code{viper-buffer-search-char} will take movement commands, like
@kbd{w,/,e}, to find a region and then search for the contents of that
region.  This command is very useful for searching for variable names, etc.,
in a program.  The search can be repeated by @kbd{n} or reversed by @kbd{N}.

@cindex incremental search

Emacs provides incremental search.  As you type the string in, the
cursor will move to the next match.  You can snarf words from the buffer
as you go along.  Incremental Search is normally bound to @kbd{C-s} and
@kbd{C-r}.  @xref{Customization}, to find out how to change the bindings
of @kbd{C-r or C-s}.
For details, @pxref{Incremental Search,,Incremental
1166
Search,emacs,The GNU Emacs Manual}.
Glenn Morris's avatar
Glenn Morris committed
1167 1168 1169 1170

@cindex query replace

Viper also provides a query replace function that prompts through the
1171
minibuffer.  It is invoked by the @kbd{Q} key in Vi state.
Glenn Morris's avatar
Glenn Morris committed
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186

@cindex mouse search

On a window display, Viper supports mouse search, i.e., you can search for a
word by clicking on it.  @xref{Viper Specials}, for details.

Finally, on a window display, Viper highlights search patterns as it finds
them.  This is done through what is known as @emph{faces} in Emacs.  The
variable that controls how search patterns are highlighted is
@code{viper-search-face}.  If you don't want any highlighting at all, put
@example
(copy-face 'default 'viper-search-face)
@end example
@vindex @code{viper-search-face}
@noindent
1187 1188 1189 1190
in your Viper customization file.  If you want to change how patterns are
highlighted, you will have to change @code{viper-search-face} to your liking.
The easiest way to do this is to use Emacs customization widget, which is
accessible from the menubar.  Viper customization group is located under the
Glenn Morris's avatar
Glenn Morris committed
1191 1192 1193 1194 1195 1196 1197
@emph{Emulations} customization group, which in turn is under the
@emph{Editing} group (or simply by typing @kbd{:customize}).  All Viper
faces are grouped together under Viper's
@emph{Highlighting} group.

Try it: it is really simple!

1198
@node Abbreviation Facilities
Glenn Morris's avatar
Glenn Morris committed
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
@section Abbreviation Facilities

@cindex abbrevs

It is possible in Emacs to define abbrevs based on the contents of the
buffer.
Sophisticated templates can be defined using the Emacs abbreviation
facilities.  @xref{Abbrevs,,Abbreviations,emacs,The GNU Emacs Manual}, for
details.

@cindex dynamic abbrevs

Emacs also provides Dynamic Abbreviations.  Given a partial word, Emacs
will search the buffer to find an extension for this word.  For instance,
one can type @samp{Abbreviations} by typing @samp{A}, followed by a keystroke
that completed the @samp{A} to @samp{Abbreviations}.  Repeated typing
will search further back in the buffer, so that one could get
@samp{Abbrevs} by repeating the
keystroke, which appears earlier in the text.  Emacs binds this to
@kbd{@key{ESC} /}, so you will have to find a key and bind the function
@code{dabbrev-expand} to that key.
Facilities like this make Vi's @kbd{:ab} command obsolete.

1222
@node Movement and Markers
Glenn Morris's avatar
Glenn Morris committed
1223 1224 1225 1226 1227
@section Movement and Markers

@cindex Ex style motion
@cindex line editor motion

Paul Eggert's avatar
Paul Eggert committed
1228
Viper can be set free from the line-limited movements in Vi, such as @kbd{l}
Glenn Morris's avatar
Glenn Morris committed
1229
refusing to move beyond the line, @key{ESC} moving one character back,
1230 1231
etc.  These derive from Ex, which is a line editor.  If your
Viper customization file contains
Glenn Morris's avatar
Glenn Morris committed
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285

@example
@code{(setq viper-ex-style-motion nil)}
@end example

@noindent
the motion will be a true screen editor motion.  One thing you must then
watch out for is that it is possible to be on the end-of-line character.
The keys @kbd{x} and @kbd{%} will still work correctly, i.e., as if they
were on the last character.

@vindex @code{viper-syntax-preference}
@cindex syntax table

The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated
deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to
understand Emacs syntax tables.  If the variable
@code{viper-syntax-preference} is set to @code{strict-vi} then
the meaning of @emph{word} is the same as in
Vi.  However, if the value is @code{reformed-vi} (the default) then the
alphanumeric symbols will be those specified by the current Emacs syntax
table (which may be different for different major modes) plus the
underscore symbol @kbd{_}, minus some non-word symbols, like '.;,|, etc.
Both @code{strict-vi} and @code{reformed-vi} work close to Vi in
traditional cases, but @code{reformed-vi} does a better job when editing
text in non-Latin alphabets.

The user can also specify the value @code{emacs}, which would
make Viper use exactly the Emacs notion of word.  In particular, the
underscore may not be part of a word.  Finally, if
@code{viper-syntax-preference} is set to @code{extended}, Viper words would
consist of characters that are classified as alphanumeric @emph{or} as
parts of symbols.  This is convenient for writing programs and in many other
situations.

@code{viper-syntax-preference} is a local variable, so it can have different
values for different major modes.  For instance, in programming modes it can
have the value @code{extended}.  In text modes where words contain special
characters, such as European (non-English) letters, Cyrillic letters, etc.,
the value can be @code{reformed-vi} or @code{emacs}.

Changes to @code{viper-syntax-preference} should be done in the hooks to
various major modes by executing @code{viper-set-syntax-preference} as in
the following example:

@example
(viper-set-syntax-preference nil "emacs")
@end example

@findex @code{viper-set-syntax-preference}

The above discussion of the meaning of Viper's words concerns only Viper's
movement commands.  In regular expressions, words remain the same as in
Emacs.  That is, the expressions @code{\w}, @code{\>}, @code{\<}, etc., use
1286
Emacs's idea of what is a word, and they don't look into the value of
Glenn Morris's avatar
Glenn Morris committed
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297
variable @code{viper-syntax-preference}.  This is because Viper doesn't change
syntax tables in fear of upsetting the various major modes that set these
tables.

@cindex textmarkers

Textmarkers in Viper remember the file and the position, so that you can
switch files by simply doing @kbd{'a}.  If you set up a regimen for using
Textmarkers, this is very useful.  Contents of textmarkers can be viewed
by @kbd{[marker}.  (Contents of registers can be viewed by @kbd{]register}).

1298
@node New Commands
Glenn Morris's avatar
Glenn Morris committed
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310
@section New Commands

These commands have no Vi analogs.

@table @kbd
@item C-x, C-c
@kindex @kbd{C-x}
@kindex @kbd{C-c}
These two keys invoke many important Emacs functions.  For example, if you
hit @kbd{C-x} followed by @kbd{2}, then the current window will be split
into 2.  Except for novice users, @kbd{C-c} is also set to execute an Emacs
command from the current major mode.  @key{ESC} will do the same, if you
1311 1312 1313 1314
configure @key{ESC} as Meta by setting @code{viper-no-multiple-ESC} to
@code{nil} in your Viper customization file.  @xref{Customization}.
@kbd{C-\} in Insert, Replace, or Vi states will make Emacs think
@kbd{Meta} has been hit.
Glenn Morris's avatar
Glenn Morris committed
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
@item \
@kindex @kbd{\}
Escape to Emacs to execute a single Emacs command.  For instance,
@kbd{\ @key{ESC}} will act like a Meta key.
@item Q
@kindex @kbd{Q}
@cindex query replace
@kbd{Q} is for query replace.  By default,
each string to be replaced is treated as a regular expression.  You can use
@code{(setq viper-re-query-replace nil)} in your @file{.emacs} file to
turn this off.  (For normal searches, @kbd{:se nomagic} will work.  Note
that @kbd{:se nomagic} turns Regexps off completely, unlike Vi).
@item v
@itemx V
@itemx C-v
@kindex @kbd{v}
@kindex @kbd{V}
@kindex @kbd{C-v}
These keys are used to visit files.  @kbd{v} will switch to a buffer
1334
visiting file whose name can be entered in the minibuffer.  @kbd{V} is
Glenn Morris's avatar
Glenn Morris committed
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
similar, but will use a window different from the current window.
@kbd{C-v} is like @kbd{V}, except that a new frame (X window) will be used
instead of a new Emacs window.
@item #
@kindex @kbd{#}
If followed by a certain character @var{ch}, it becomes an operator whose
argument is the region determined by the motion command that follows
(indicated as <move>).
Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q}, and
@kbd{s}.  For instance, @kbd{#qr} will prompt you for a string and then
1345
prepend this string to each line in the buffer.
Glenn Morris's avatar
Glenn Morris committed
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
@item # c
@kindex @kbd{#c<move>}
@cindex changing case
Change upper-case characters in the region to lower-case
(@code{downcase-region}).
Emacs command @kbd{M-l} does the same for words.
@item # C
@kindex @kbd{#C<move>}
Change lower-case characters in the region to upper-case.  For instance,
@kbd{# C 3 w} will capitalize 3 words from the current point
(@code{upcase-region}).
Emacs command @kbd{M-u} does the same for words.
@item # g
@kindex @kbd{#g<move>}
Execute last keyboard macro for each line in the region
1361
(@code{viper-global-execute}).
Glenn Morris's avatar
Glenn Morris committed
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406
@item # q
@kindex @kbd{#q<move>}
Insert specified string at the beginning of each line in the region
(@code{viper-quote-region}).  The default string is composed of the comment
character(s) appropriate for the current major mode.
@item # s
@kindex @kbd{#s<move>}
Check spelling of words in the region (@code{spell-region}).
The function used for spelling is determined from the variable
@code{viper-spell-function}.
@vindex @code{viper-spell-function}
@item *
@kindex @kbd{*}
Call last keyboard macro.
@item m .
Set mark at point and push old mark off the ring
@item m<
@item m>
Set mark at beginning and end of buffer, respectively.
@item m,
Jump to mark and pop mark off the ring.  @xref{Mark,,Mark,emacs,The GNU
Emacs Manual}, for more info.
@item ] register
@kindex @kbd{]<a-z>}
View contents of register
@item [ textmarker
@kindex @kbd{[<a-z>}
View filename and position of textmarker
@item @@#
@item @@register
@item @@!
@kindex @kbd{@@#}
@kindex @kbd{@@<a-z>}
@kindex @kbd{@@!}
@cindex keyboard macros
@cindex register execution

Begin/end keyboard macro.  @@register has a different meaning when used after
a @kbd{@@#}.  @xref{Macros and Registers}, for details
@item []
@kindex @kbd{[]}
Go to end of heading.
@item g <@emph{movement command}>
Search buffer for text delimited by movement command.  The canonical
example is @kbd{gw} to search for the word under the cursor.
1407
@xref{Improved Search}, for details.
Glenn Morris's avatar
Glenn Morris committed
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433
@item C-g and C-]
@kindex @kbd{C-g}
@kindex @kbd{C-]}
Quit and Abort Recursive edit.  These may be necessary on occasion.
@xref{Vi State}, for a reason.
@item C-c C-g
@kindex @kbd{C-c C-g}
Hitting @kbd{C-c} followed by @kbd{C-g} will display the information on the
current buffer.  This is the same as hitting @kbd{C-g} in Vi, but, as
explained above, @kbd{C-g} is needed for other purposes in Emacs.
@item C-c /
@kindex @kbd{C-c /}
Without a prefix argument, this command toggles
case-sensitive/case-insensitive search modes and plain vanilla/regular
expression search.  With the prefix argument 1, i.e.,
@kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2,
toggles plain vanilla search and search using
regular expressions.  @xref{Viper Specials}, for alternative ways to invoke
this function.
@cindex vanilla search
@cindex case-sensitive search
@cindex case-insensitive search

@item M-p and M-n
@kindex @kbd{M-p}
@kindex @kbd{M-n}
1434
In the minibuffer, these commands navigate through the minibuffer
Glenn Morris's avatar
Glenn Morris committed
1435 1436
histories, such as the history of search strings, Ex commands, etc.

1437 1438 1439 1440 1441 1442 1443
@item C-s
@kindex @kbd{C-s}
If the minibuffer is entered via a Viper search commands @kbd{/} or @kbd{?},
then typing this key inserts the last search string used by the
Emacs incremental search command (that is bound to @kbd{C-s} everywhere
except in this case).

Glenn Morris's avatar
Glenn Morris committed
1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460
@item C-c M-p and C-c M-n
@kindex @kbd{C-c M-p}
@kindex @kbd{C-c M-n}
@cindex Insertion history
@cindex Insertion ring
@cindex Command history
@cindex Command ring

In Insert or Replace state, these commands let  the user
peruse the history of insertion strings used in previous insert or replace
commands.  Try to hit @kbd{C-c M-p} or @kbd{C-c M-n} repeatedly and see what
happens.  @xref{Viper Specials}, for more.

In Vi state, these commands let the user peruse the history of Vi-style
destructive commands, such as @kbd{dw}, @kbd{J}, @kbd{a}, etc.
By repeatedly typing @kbd{C-c M-p} or @kbd{C-c M-n} you will cycle Viper
through the recent history of Vi commands, displaying the commands one by
1461 1462
one.  Once an appropriate command is found, it can be executed by
typing a period.
Glenn Morris's avatar
Glenn Morris committed
1463 1464 1465 1466 1467 1468

Since typing @kbd{C-c M-p} is tedious, it is more convenient to bind an
appropriate function to a function key on the keyboard and use that key.
@xref{Viper Specials}, for details.

@item Ex commands
1469 1470 1471 1472
@findex  @kbd{Ex args}
@findex  @kbd{Ex n}
@findex  @kbd{Ex pwd}
@findex  @kbd{Ex pre}
Glenn Morris's avatar
Glenn Morris committed
1473 1474 1475 1476 1477 1478 1479
The commands @kbd{:args}, @kbd{:next}, @kbd{:pre} behave
differently.  @kbd{:pwd} exists to get current directory.
The commands @kbd{:b} and @kbd{:B} switch buffers around.  @xref{File and
Buffer Handling}, for details.
There are also the new commands @kbd{:RelatedFile} and
@kbd{PreviousRelatedFile} (which abbreviate to @kbd{R} and @kbd{P},
respectively.  @xref{Viper Specials}, for details.
1480 1481
@findex @kbd{Ex RelatedFile}
@findex @kbd{Ex PreviousRelatedFile}
Glenn Morris's avatar
Glenn Morris committed
1482 1483 1484 1485 1486 1487
@end table

Apart from the new commands, many old commands have been enhanced.  Most
notably, Vi style macros are much more powerful in Viper than in Vi.  @xref{Vi
Macros}, for details.

1488
@node Useful Packages
Glenn Morris's avatar
Glenn Morris committed
1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565
@section Useful Packages

Some Emacs packages are mentioned here as an aid to the new Viper user, to
indicate what Viper is capable of.
A vast number comes with the standard Emacs distribution, and many more exist
on the net and on the archives.

This manual also mentions some Emacs features a new user
should know about.  The details of these are found in the GNU Emacs
Manual.

The features first.  For details, look up the Emacs Manual.

@table @samp
@item Make
@cindex make
@cindex compiling

Makes and Compiles can be done from the editor.  Error messages will be
parsed and you can move to the error lines.
@item Shell
@cindex shell
@cindex interactive shell
You can talk to Shells from inside the editor.  Your entire shell session
can be treated as a file.
@item Mail
@cindex email
@cindex mail
Mail can be read from and sent within the editor.  Several sophisticated
packages exist.
@item Language Sensitive Editing
Editing modes are written for most computer languages in existence.  By
controlling indentation, they catch punctuation errors.
@end table

The packages, below, represents a drop in the sea of special-purpose
packages that come with standard distribution of Emacs.

@table @samp
@item Transparent FTP
@cindex transparent ftp
@pindex ange-ftp.el
@code{ange-ftp.el} can ftp from the editor to files on other machines
transparent to the user.
@item RCS Interfaces
@cindex version maintenance
@cindex RCS
@pindex vc.el
@code{vc.el} for doing RCS commands from inside the editor
@item Directory Editor
@cindex dired
@pindex dired.el
@code{dired.el} for editing contents of directories and for navigating in
the file system.
@item Syntactic Highlighting
@cindex font-lock
@pindex font-lock.el
@code{font-lock.el} for automatic highlighting various parts of a buffer
using different fonts and colors.
@item Saving Emacs Configuration
@cindex desktop
@pindex desktop.el
@code{desktop.el} for saving/restoring configuration on Emacs exit/startup.
@item Spell Checker
@cindex ispell
@pindex ispell.el
@code{ispell.el} for spell checking the buffer, words, regions, etc.
@item File and Buffer Comparison
@cindex ediff
@pindex ediff.el
@code{ediff.el} for finding differences between files and for applying
patches.
@end table

@noindent
Emacs Lisp archives exist on
@samp{archive.cis.ohio-state.edu}
1566
and @samp{wuarchive.wustl.edu}
Glenn Morris's avatar
Glenn Morris committed
1567 1568


1569
@node Customization
Glenn Morris's avatar
Glenn Morris committed
1570 1571 1572 1573 1574 1575 1576 1577 1578 1579
@chapter Customization

@cindex customization

Customization can be done in 2 ways.

@itemize @bullet
@item
@cindex initialization
@cindex .viper
1580 1581 1582
Elisp code in a @file{~/.emacs.d/viper} (or @file{~/.viper}) file.
Viper loads this file just before it does the binding for mode hooks.
This is recommended for experts only.
Glenn Morris's avatar
Glenn Morris committed
1583 1584 1585 1586 1587 1588
@item
@cindex .emacs
Elisp code in your @file{.emacs} file before and after the @code{(require
'viper)} line.  This method is @emph{not} recommended, unless you know what
you are doing.  Only two variables, @code{viper-mode} and
@code{viper-custom-file-name}, are supposed to be customized in @file{.emacs},
1589
prior to loading Viper (i.e., prior to @code{(require 'viper)} command.
Glenn Morris's avatar
Glenn Morris committed
1590
@item
1591
@cindex Ex customize
Glenn Morris's avatar
Glenn Morris committed
1592 1593 1594 1595 1596
By executing the @kbd{:customize} Ex command. This takes you to the Emacs
customization widget, which lets you change the values of Viper
customizable variables easily. This method is good for novice and
experts alike. The customization code in the form of Lisp commands will be
placed in @file{~/.emacs} or some other customization file depending on the
1597
version of Emacs that you use.  Still, it is recommended to separate
Glenn Morris's avatar
Glenn Morris committed
1598
Viper-related customization produced by the Emacs customization widget
Glenn Morris's avatar