# 4. EX COMMAND MODE

Ex is an editing mode in which Elvis acts like a line editor. This means that you type in a command line, and when the line is complete Elvis executes it on the current text buffer. I.e., in ex each line (or group of lines) is a command, as opposed to vi where each character (or group of characters) is a command. The commands are listed below either grouped by function or listed in alphabetical order.

Typically, ex commands are used to do perform complex actions such as global search & replace, or actions which require an argument such as writing the edit buffer out to a different file.

Ex is also used as the configuration language for Elvis; configuration scripts such as elvis.ini, .exrc (or elvis.rc), and elvis.arf contain a series of ex commands.

You can switch freely between vi and ex. If you're in vi mode, you can enter a single ex command line via the visual : command, or more permanently switch via the visual Q command. If you're in ex mode, you can switch to vi mode via ex's :vi command.

Normally Elvis will start in vi mode, but you can force it to start in ex mode by supplying a -e command line flag. On UNIX systems, you can link Elvis to a name which ends with "x" to achieve the same effect.

The remainder of this section discusses how to enter lines, the general syntax of an ex command line, and the specific commands which Elvis supports.

## 4.1 Entering lines

In Elvis, when you're typing in an ex command line you're really inputting text into a buffer named "Elvis ex history". All of the usual input mode commands are available, including `Backspace` to erase the previous character, `Control-W` to erase the previous word, and so on.

Any previously entered lines will still be in the "Elvis ex history" buffer, and you can use the arrow keys to move back and edit earlier commands. You can even use the `Control-O` input-mode command with the ?regexp visual command, to search for an earlier command line.

When you hit the `Enter` key on a line in the "Elvis ex history" buffer, Elvis sends that line to the ex command parser, which is described in the next section.

### 4.1.1 An example

Suppose you enter the command...

    	:e ~/proj1/src/header.h

...and then realize that you really wanted "header2.h" instead of "header.h". You simplest way to get "header2.h" is to...

1. Hit the `:` key to start a new ex command line.
2. Hit the `Up` arrow key, or `^O k` to move back to the preceding command line (which was "`:e ~/proj1/src/header.h`"). `^O k` works because `^O` reads and executes one vi command, and the `k` vi command moves the cursor back one line. The `Up` arrow key works because it is mapped to "visual k", which does exactly the same thing as `^O k`.
3. Hit the `Left` arrow key twice, or `^O 2 h`, to move the cursor back to the '.' character in "header.h".
4. Hit `2` to insert a '2' before the '.' character. At this point, the line should look like "`:e ~/proj1/src/header2.h`".
5. Hit `Enter` to submit the revised command line.

Or suppose you really wanted "footer2.h" instead of "header2.h". This is a little trickier because you want to delete characters in the middle of the command line, before inserting the correct text. The simplest way to do this is move the cursor to a point just after the last character that you want to delete, and then backspace over them. The steps are:

1. Hit the `:` key to start a new ex command line.
2. Hit the `Up` arrow key or `^O k` repeatedly to move back to the "`:e ~/proj1/src/header2.h`"command line.
3. Hit the `Left` arrow key five times, or `^O 5 h`, to move the cursor back to the last 'e' character in "header2.h".
4. Hit the `Backspace` key four times to delete the word "head". It will still show on the screen, but Elvis will know that it has been deleted. This is the same sort of behavior that Elvis (and vi) exhibits when you backspace over newly entered text in input mode.
5. Type `f o o t` to insert "foot" where "head" used to be. At this point, the line should look like "`:e ~/proj1/src/footer2.h`".
6. Hit `Enter` to submit the revised command line.

### 4.1.2 The TAB key

The `Tab` key has a special function when you're inputting text into the "Elvis ex history" buffer. It is used for name completion. (Exception: Under MS-DOS, this feature is disabled in order to reduce the size of the program, so it will fit in the lower 640K.)

Name completion works like this: The preceding word is assumed to be a partial name for an ex command, an option, a tag, or a file. The type of name is determined by the context in which it appears -- commands appear at the start of an ex command line, and the others can only occur after certain, specific command names. Elvis searches for all matches of the appropriate type.

If there are multiple matches, then Elvis fills in as many characters of the name as possible, and then stops; or, if no additional characters are implied by the matching names, then Elvis lists all matching names and redisplays the command line. If there is a single match, then Elvis completes the name and appends a space character or some other appropriate character. If there are no matches, then Elvis simply inserts a tab character.

Also, if while entering a :set command you hit the `Tab` key immediately after "option=" then Elvis will insert the current value of the option. You can then edit that value before submitting the command line.

I tried to make Elvis smart enough that the `Tab` key will only attempt file/command/option completion in contexts where it makes sense to do so, but that code might not be 100% correct. You can bypass the completion by typing a `Control-V` before the `Tab` key. You can also disable name completion altogether by setting the "Elvis ex history" buffer's inputtab option to "tab", via the following command:

    	:(Elvis ex history)set inputtab=tab

or the abbreviated form:

    	:("Eeh)se it=t

By default, Elvis ignores binary files when performing filename completion. The completebinary option can be used to make Elvis include binary files. That's a global option (unlike inputtab which is associated with a specific buffer), so you don't need to specify the buffer name; a simple `:set completebinary` will set it.

## 4.2 Syntax and Addressing

In general, ex command lines can begin with an optional window id. This may be followed by an optional buffer id, and then 0, 1, or 2 line addresses, followed by a command name, and perhaps some arguments after that (depending on the command name).

A window ID is typed in as a decimal number followed by a colon character. If you don't supply a window ID (and you almost never will) then it defaults to the window where you typed in the command line. The :buffer command lists the buffers, and shows which one is being edited in which window. Also, the windowid option indicates the ID of the current window.

A buffer ID is given by typing an opening parenthesis, the name of the buffer, and a closing parenthesis. For user buffers, the name of the buffer is usually identical to the name of the file that it corresponds to. For example, a file named .Xdefaults would be loaded into a buffer which could be addressed as `(.Xdefaults)`. Elvis also assigns numbers to user buffers, which may be more convenient to type since numbers are generally shorter than names. If .Xdefaults is the first file you've edited since starting Elvis, then its buffer could be addressed as `(#1)`. The :buffer command shows the number for each user buffer.

Elvis also has several internal buffers, all of which have names that start with "Elvis ", such as `(Elvis cut buffer x)` and `(Elvis error list)`. The :buffer! command (with a ! suffix) will list them all. For the sake of brevity, Elvis allows you to refer to cut buffers as `("x)`. Similarly, the other internal buffers can be referred to via a " character and the initial letter in each word of the full name, such as `("Eel)` for `(Elvis error list)`.

The parentheses can also contain an '=' followed by an expression, in which case Elvis will evaluate the expression and use the result as the buffer name. For example, if the x option is set to "run2000", then "`:(=x)%p`" is equivalent to "`:(run2000)%p`". (They both print the contents of the buffer named "run2000".) This is often handy in aliases.

Commands which don't access the text, such as ":quit", don't allow any line addresses. Other commands, such as ":mark", only allow a single line address. Most commands, though, allow two line addresses; the command is applied to all lines between the two specified lines, inclusively. The tables below indicate how many line addresses each command allows.

Line addresses are always optional. The first line address of most commands usually defaults to the current line. The second line address usually defaults to be the same as the first line address. Exceptions are :write, :lpr, :global, and :vglobal, which act on all lines of the file by default, and :!, which acts on no lines by default.

If you use the visual V command to mark a range of lines, and then use the visual : command to execute a single ex command, then the default range affected by the ex command will be the visibly marked text.

Line addresses consist of an absolute part and a relative part. The absolute part of a line specifier may be either an explicit line number, a mark, a dot to denote the current line, a dollar sign to denote the last line of the file, or a forward or backward search. An explicit line number is simply a decimal number, expressed as a string of digits. A mark is typed in as an apostrophe followed by a letter. Marks must be set before they can be used. You can set a mark in visual command mode by typing "m" and a letter, or you can set it in ex command mode via the "mark" command. A forward search is typed in as a regular expression surrounded by slash characters; searching begins at the default line. A backward search is typed in as a regular expression surrounded by question marks; searching begins at the line before the default line.

If you omit the absolute part, then the default line is used.

The relative part of a line specifier is typed as a `+` or `-` character followed by a decimal number. The number is added to or subtracted from the absolute part of the line specifier to produce the final line number.

To use a range of addresses, give the expressions for the first and last line separated by either a comma or semicolon. When separated by a comma, both lines are addressed relative to the default line (where the cursor is, generally). When separated by a semicolon, the second address will be relative to the first address. You can also give more than two addresses, in which case the last two will define the range.

As a special case, the `%` character may be used to specify all lines of the file. It is roughly equivalent to saying `1,$`. This can be a handy shortcut.

Here are some addressing examples, using the :p command:

       COMMAND      | ACTION
       -------------|-------------------------------------------
       :p           | print the current line
       :37p         | print line 37
       :'gp         | print the line which contains mark g
       :/foo/p      | print the next line that contains "foo"
       :$p          | print the last line of the buffer
       :20,30p      | print lines 20 through 30
       :1,$p        | print all lines of the buffer
       :%p          | print all lines of the buffer
       :(zot)%p     | print all lines of the "zot" buffer
       :/foo/-2,+4p | print 5 lines around the next "foo"

The optional addresses are followed by the command name. Command names may be abbreviated. In the sections that follow, the command's full name is given with the optional part enclosed in square brackets.

Some commands allow a '!' character to appear immediately after the command name. The significance of the '!' varies from one command to another, but typically it forces the command to do something dangerous that it would ordinarily refuse to do. For example, :w file refuses to overwrite an existing file, but :w! file will do it.

Many commands allow (or even require) additional arguments. The descriptions below list which arguments each command accepts with optional commands denoted by square brackets. The most common argument types are:

/regexp/
  This is a regular expression. You can use any punctuation character to delimit it, but the '/' character is the most commonly used.
/regexp/newtext/
  This is a regular expression followed by replacement text.
count
  This is a number - a string of digits. Generally, it is used as the repeat count for certain commands.
cutbuf
  This is the name of a cut buffer - a single letter. Elvis also allows (but does not require) a quote character before the letter.
excmds
  This is another ex command, or list of ex commands. Traditionally, the whole list of commands had to appear on the same line, delimited by '|' characters. Elvis has the added versatility of allowing a '{' character on the first line, each command on a separate following line, and then '}' on a line by itself to mark the end of the ex command list.
lhs
  This is string of characters. If whitespace characters are to be included in it, then they must be quoted by embedding a `^V` character before them.
face
  This is the name of a text face -- that is, a type of text. The :color command is used to configure the appearance of the face, and :check defines the spell-checking rules.
line
  This is a line address, as described earlier.
+line
  Some commands which cause a file to be loaded also allow you to specify some other command to be executed after the loading is complete. To use this feature, you mist give a "+" followed by the command, in between the command name and the file name. Here's an example that loads foo and then moves the cursor to line 40.

      	:e +40 foo

  Usually the command is just a line number, so this is denoted as "+line" in this documentation. Other commands are allowed though, such as "+/text" to search for text, or "+normal" to force it to use the normal display mode.

  Traditionally, commands supplied in this manner weren't allowed to contain whitespace, because that makes parsing the command line harder. This is too limiting, though, so Elvis allows you to embed spaces in the command by wrapping the entire deferred command in double-quotes, like this:

      	:e +"set bufdisplay=man" filedb.8

mark
  This is the name of a mark - a single lowercase letter. Elvis allows (but does not require) an apostrophe before the letter.
rhs
  This is a string of characters. If it begins with a whitespace character, then that character must be quoted by embedding a `^V` character in the command line before it. Other whitespace characters in the string do not need to be quoted.
expr
  This is an arithmetic expression using the normal syntax.
shellcmd
  This is a command line which is passed to the system's command interpreter. Within the command line, the following character substitutions take place, unless preceded by a backslash:

      	.-----------.----------------------------.
      	| CHARACTER | REPLACED BY                |
      	|-----------|----------------------------|
      	|     %     | Name of current file       |
      	|     #     | Name of alternate file     |
      	|     #n    | Name of file whose bufid=n |
      	|     !     | Previous command line      |
      	|     \@    | Word at cursor location    |
      	^-----------^----------------------------^

  Note that the `\@` substitution requires a backslash. This quirk exists for the sake of backward compatibility - the real vi doesn't perform any substitutions for just plain @, and neither does Elvis.
file or files
  This is one or more file names, or a "wildcard" pattern which matches the names of zero or more files. File names are subjected to three levels of processing. First, leading ~ characters and certain other characters are replaced with text, as follows:

          .-----------.------------------------------------------------.
          | SYMBOL    | REPLACED BY                                    |
          |-----------|------------------------------------------------|
          | ~user     | (Unix only) Replaced by home directory of user |
          | ~+        | Replaced by current working directory          |
          | ~-        | Replaced by previous directory (previousdir)   |
          | ~         | Replaced by home directory (home)              |
          | %         | Replaced by the name of the current file       |
          | #         | Replaced by the name of the alternate file     |
          | #n        | Replaced by the filename of buffer with bufid=n|
          | (space)   | Delimits one file name from another            |
          | `program` | Run program, interpret its output as filenames |
          ^-----------^------------------------------------------------^

  The second stage of processing evaluates each name using the simpler expression syntax. This basically means that expressions of the form $NAME will be replaced with the value of the environment variable named NAME. Also, you can use parentheses around option names or more complex expressions. For example, if the user option f contains the name of a file, then you could say "`:e (f)`" to edit that file.

  In either of the first two stages, backslashes may be used to prevent the special symbols from having their usual meaning; they'll be treated as normal text instead. In particular, a backslash-space sequence can be used to give a filename which includes spaces; e.g., to edit "C:\Program Files\foo" you would type "`:e C:\Program\ Files\foo`". Note that backslashes which are followed by a normal character are simply retained as normal characters, so you rarely need to type a double-backslash when your file name needs only a single backslash.

  The third stage of processing checks for "wildcard" characters in the name, and if there are any then the whole name is replaced by the name of each matching file. The exact list of supported wildcards will vary from one operating system to another, but the following are typical:

      	.--------.----------------------------------------------.
      	| SYMBOL | MATCHES                                      |
      	|--------|----------------------------------------------|
      	| *      | Any string of characters, of any length      |
      	| ?      | Any single character                         |
      	| [A-Z]  | (Unix only) Any single character from A to Z |
      	^--------^----------------------------------------------^

  In most operating systems, wildcards are only recognized when they occur in the last file name part of a longer pathname. In other words, you can use wildcards for file names, but not in directory names leading up to file names.

  Traditionally, vi has used the Unix shell to expand wildcards. However, this interferes with the use of spaces in file names, isn't easily portable to non-Unix operating systems, and is a potential security hole. So Elvis performs all wildcard expansion itself. The only disadvantage of this is that you loose other shell notations such as `{alt1,alt2}`.

Most commands can be followed by a '|' character and another ex command. Others can't. In particular, any command which takes a excmd or shellcmd argument doesn't treat '|' as a command delimiter.

If a command does treat '|' as a delimiter, and you want '|' to be treated as part of a command argument, then you'll need to quote the '|' character by preceding it with a backslash or ^V, depending on the command. (Sadly, different commands require different quote characters.)

## 4.3 Ex Commands, Grouped by Function

- 4.4 The help command itself
- 4.5 Editing commands
- 4.6 Global edit commands
- 4.7 Displaying text
- 4.8 Tags
- 4.9 File I/O commands
- 4.10 The args list, and selecting a file to edit
- 4.11 Quitting
- 4.12 Scripts and macros
- 4.13 Working with a compiler
- 4.14 Built-in calculator
- 4.15 Buffer commands
- 4.16 Window commands
- 4.17 Configuration
- 4.18 Auto commands
- 4.19 Folding
- 4.20 Regions
- 4.21 Spell checking
- 4.22 Miscellaneous

## 4.4 The help command itself

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | h[elp]            | topic                             |
    ^-------^-------------------^-----------------------------------^

h[elp] topic
  The `:help` command loads and displays a help file for a given topic. There are several help files, covering a wide variety of topics.

  Elvis looks at the topic you supply, and tries to determine whether it is an ex command name, vi keystroke, option name, or something else. Based on this, it generates a hypertext link to the topic in the appropriate help file, and shows the topic in a separate window. Elvis uses the following rules to convert your requested topic into a hypertext reference:

        .-------------------.-------------------------------------------.
        | COMMAND           | ELVIS' INTERPRETATION                     |
        |-------------------|-------------------------------------------|
        | :help             | With no topic, Elvis loads the table of   |
        |                   |   contents. This has hypertext links that |
        |                   |   can lead you to any other topic.        |
        | :help ex          | Elvis loads the chapter describing ex     |
        |                   |   commands.                               |
        | :help vi          | Elvis loads the chapter describing vi     |
        |                   |   commands.                               |
        | :help set XXX     | If XXX is an option name, Elvis will show |
        |                   |   the description of that option; else it |
        |                   |   will list groups of all options.        |
        | :help display XXX | If XXX is the name of a display mode, then|
        |                   |   Elvis will show the description of that |
        |                   |   mode.  Otherwise it shows the top of the|
        |                   |   display mode chapter                    |
        | :help autocmd XXX | If XXX is the name of an autocmd event,   |
        |                   |   then Elvis will show the description of |
        |                   |   that event; else it will take you to the|
        |                   |   top of the event list                   |
        | :help :XXX        | If XXX is an ex command name, Elvis will  |
        |                   |   show its description; else Elvis will   |
        |                   |   list groups of all ex commands.         |
        | :help XXX()       | Elvis loads the chapter describing the    |
        |                   |   built-in calculator, and moves to the   |
        |                   |   section describing function XXX.        |
        | :help <XXX>       | Describe Elvis' implementation of the HTML|
        |                   |   tag <XXX>                               |
        | :help XXX         | If XXX appears to be a keystroke then     |
        |                   |   Elvis will assume it is meant to be a   |
        |                   |   vi command and will show the command's  |
        |                   |   description.  Else if it is an option   |
        |                   |   name Elvis will show that. Else if it   |
        |                   |   is an ex command, Elvis will show that. |
        |                   |   Else Elvis will show this description   |
        |                   |   of the :help command itself.            |
        ^-------------------^-------------------------------------------^

  Although this chart only mentions chapters on ex commands, vi commands, options, functions, autocmd events, and html tags, there are many other chapters which are only accessible via the table of contents shown by ":help" with no arguments.

  All of these help files are HTML documents. Elvis' standard HTML editing facilities are available while you're viewing the help text. Some of the highlights of this are:

  - To close this help window, type `ZQ`. Actually, this works for all windows. (You must hold the `Shift` key as you type `ZQ`, because lowercase `zq` does something else entirely: nothing!)
  - Any underlined text is a hypertext reference. This means that you can move the cursor onto it, and hit ^] (Control-]) and the cursor will move to a topic describing the underlined text. Usually when viewing HTML documents, the `Enter` key will be mapped to `^]` so you can use it too.
  - To return to your original position after following a hypertext reference, hit ^T (Control-T).
  - The Tab key moves the cursor forward to the next hypertext reference.

  You can use Elvis to print the document via the :lpr command. This assumes you have set the printing options correctly.

NOTE: In addition to the :help command, most versions of Elvis also support two aliases which you may find handy. The ":howto words..." alias searches for given words in the title lines of a short "howto.html" document. The ":kwic word" alias finds every instance of a given word in any section of Elvis' documentation, and builds a table showing each instance along with some of the surrounding text; you can then follow hypertext links to the actual location in the manual.

## 4.5 Editing commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | line  | a[ppend][!]       | [text]                            |
    | line  | i[nsert][!]       | [text]                            |
    | range | c[hange][!]       | [count]                           |
    | range | d[elete]          | [cutbuf] [count]                  |
    | range | y[ank]            | [cutbuf] [count]                  |
    | line  | pu[t]             | [cutbuf]                          |
    | range | co[py]            | line                              |
    | range | m[ove]            | line                              |
    | range | t[o]              | line                              |
    | range | !                 | shellcmd                          |
    | range | >                 |                                   |
    | range | <                 |                                   |
    | range | j[oin][!]         |                                   |
    |       | u[ndo]            | [count]                           |
    |       | red[o]            | [count]                           |
    ^-------^-------------------^-----------------------------------^

line a[ppend]`[`!`]` `[`text`]`
  The `:append` command inserts text after the current line. If no new text is supplied on the command line, then Elvis will wait for you to type in text; you can then mark the end of the new text by typing a "." (period) on a line by itself. In the real vi, adding a '!' suffix temporarily toggles the autoindent option, but Elvis just ignores the '!'.
line i[nsert]`[`!`]` `[`text`]`
  The `:insert` command inserts text before the current line. Other than that, it is identical to the :append command. In the real vi, adding a '!' suffix temporarily toggles the autoindent option, but Elvis just ignores the '!'.
range c[hange]`[`!`]` `[`count`]` `[`text`]`
  The `:change` command deletes old text lines (copying them into the anonymous cut buffer) and then waits for you to enter new text to replace it. You can then mark the end of the new text by typing a "." (period) on a line by itself. In the real vi, adding a '!' suffix temporarily toggles the autoindent option, but Elvis just ignores the '!'.
range d[elete] `[`cutbuf`]` `[`count`]`
range y[ank] `[`cutbuf`]` `[`count`]`
  The `:delete` command copies text into a cut buffer, and then deletes it from the edit buffer. The `:yank` command copies text into a cut buffer but leaves the edit buffer unchanged.
line pu[t] `[`cutbuf`]`
  The `:put` command "pastes" text from a cut buffer back into the edit buffer. The cut buffer's contents are inserted after the addressed line. If you want to insert before the first line, you can use address 0 like this:

      :0put

range co[py] line
range t[o] line
  The `:copy` and `:to` commands are identical. They both make a copy of a portion of an edit buffer, and insert that copy at a specific point. The destination line can be specified with an optional buffer name and the full address syntax as described in section 4.2. Consequently, you can use this command to copy part of one edit buffer into another edit buffer. The following example copies an 11-line window from the current buffer onto the end of a buffer named "otherbuf"

      :-5,+5t(otherbuf)$

range m[ove] line
  The `:move` command resembles :copy except that `:move` deletes the original text.
range ! shellcmd
  The `:!` command allows you to send parts of your edit buffer though some external "filter" program. The output of the program then replaces the original text. For example, this following will sort lines 1 through 10 using the "sort" program.

      :1,10!sort

  If you use the `:!` command without any line addresses, then Elvis will simply execute the program and display its output. This is only guaranteed to work correctly for non-interactive programs; to execute an interactive program you should use the :shell command.

range <
range >
  The `:<` and `:>` commands adjust the indentation on the addressed lines. The `:<` command decreases the leading whitespace by the number of spaces indicated in the shiftwidth option, and `:>` does the reverse. You can use multiple < or > characters in a single command to increase the shift amount; for example, `:>>>` shifts text by triple the shiftwidth amount. Normally Elvis' versions of these commands will leave blank lines unchanged, but if you append a '!' (as in `:>!`) then the command will affect blank lines in addition to other lines.
range j[oin]`[`!`]`
  The `:join` command joins multiple lines together so they form one long line. Normally it will intelligently decide how much whitespace it should place between lines, depending on the sentenceend, sentencegap, and sentencequote options. When invoked with a '!' suffix (as in `:join!`), it joins the lines without doing fancy things to whitespace.
u[ndo] `[`count`]`
red[o] `[`count`]`
  The `:undo` command undoes recent changes. The number of undoable changes is controllable on a buffer-by-buffer basis, via the undolevels option. The `:redo` command undoes an undo.

## 4.6 Global edit commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | range | g[lobal][!]       | /regexp/ excmds                   |
    | range | v[global][!]      | /regexp/ excmds                   |
    | range | s[ubstitute]      | /regexp/new/[g|.n][x][c][e][p|l|#]|
    | range | &                 | [g|.n][p|l|#][x][c]               |
    | range | ~                 | [g|.n][p|l|#][x][c]               |
    |       | noh[lsearch]      |                                   |
    ^-------^-------------------^-----------------------------------^

range g[lobal]`[`!`]` /regexp/ excmds
range v[global]`[`!`]` /regexp/ excmds
  The `:global` command searches for lines which contain the /regexp/ and executes the given excmds for each matching line. The `:vglobal` command executes the excmds for each line which does not match the /regexp/.

  In script files, you can supply multiple command lines to a single `:global` or `:vglobal` by placing a '{' character on the `:global/:vglobal` line, following that with any number of command lines, and then finally a '}' character on a line by itself to mark the end. This notation doesn't allow nesting; you can't use {...} inside a larger {...} command list. (Hopefully this limitation will be lifted soon.)

range s[ubstitute] /regexp/new/`[`g`|`.instance`][`c`][`x`][`e`][`p`|`l`|`#`][`count`]`
  The `:substitute` command searches for the /regexp/ in each line, and replaces the matching text with newtext. The interpretation of new text is described in section 5.2

  Briefly, flags supported by `:s` are...

      .------.-------------------------------------------------------.
      | FLAG | WHAT IT MEANS                                         |
      |------|-------------------------------------------------------|
      |  g   | replace every instance in each line                   |
      |  .n  | (n is a number) replace the n'th instance in each line|
      |  c   | ask for confirmation before making the change         |
      |  x   | execute the newtext as an ex command; don't subsitute |
      |  e   | don't treat "no match" as an error                    |
      |  p   | print the changed line like :p                        |
      |  l   | print the changed line like :l                        |
      |  #   | print the changed line like :nu                       |
      ^------^-------------------------------------------------------^

  The newtext can be followed by a `g` flag to replace all instances in each line. Without the `g` flag, only the first match within each line is changed (unless the gdefault option is set). To replace some other instance in each line, give a decimal point followed by the instance number, such as `.3` to replace the third instance of matching text in each line.

  You can also supply a `p` flag. This causes each affected line to be printed (like :p), after all substitutions have been made to that line. Similarly, `l` lists it (like :l), and `#` prints it with a line number (like :nu or :#).

  You can also make Elvis ask for confirmation before each substitution by appending a `c` flag. The `:s` command will locate the first match and then exit immediately, but it will leave the window in an unusual input state in which `y` performs a substitution and then moves on to the next match, `n` does not perform the substitution but still moves to the next match, and `Esc` cancels the operation. Most other keys act like `y` in this mode.

  NOTE: Elvis doesn't allow the `c` flag to be combined with the :g command. Instead of using "`:g/regexp/s//newtext/gc`", I suggest you get in the habit of using "`:%s/regexp/newtext/gc`". There is no way to do the more complex "`:g/regexp1/s/regexp2/newtext/gc`" in Elvis at this time.

  Elvis supports a special `x` flag. Instead of performing each substitution, Elvis will execute the final replacement text as an ex command line. This is used in the implementation of modelines, like this:

      	try 1,5 s/ex:\(.*\):/\1/x
      	try $-4,$ s/ex:\(.*\):/\1/x

  The :try command is there so that if no modelines are found, Elvis won't consider that to be an error. This is important because an error would cause the script to be aborted. Another way to avoid errors when there is no match is to use the `e` flag.

range &`[`g`|`.instance`][`c`][`p`|`n`|`#`][`x`][`count`]`
range ~`[`g`|`.instance`][`c`][`p`|`n`|`#`][`x`][`count`]`
  The `:&` and `:~` commands both repeat the previous `:substitute` command, discarding any previous flags. The difference between them is that `:&` uses the regular expression from the previous `:s` command, but `:~` uses the most recent regular expression from any context.
noh[lsearch]
  The `:nohlsearch` temporarily disables the hlsearch option's highlighting. It doesn't change that option's value; it merely makes Elvis forget that it was supposed to highlight anything. The next time you perform a search, the `hlsearch` option will again highlight the matching text.

## 4.7 Displaying text

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | range | p[rint]           | [count]                           |
    | range | l[ist]            | [count]                           |
    | range | nu[mber]          | [count]                           |
    | range | #                 | [count]                           |
    | line  | z                 | [spec]                            |
    | range | =                 |                                   |
    ^-------^-------------------^-----------------------------------^

range p[rint] `[`count`]`
  The `:print` command displays lines from the edit buffer. It displays them the normal way -- with tabs expanded and so on.
range l[ist] `[`count`]`
  The `:list` command also displays lines, but it tries to make all non-printing characters visible, and it marks the end of each line with a '$' character.
range nu[mber] `[`count`]`
range # `[`count`]`
  The `:number` and `:#` commands are identical to each other. They both display lines the normal way except that each line is preceded by its line number.
line z `[`spec`]`
  The `:z` command shows a "window" of lines surrounding the current line. The default size of the "window" is taken from the window option. If a line address is supplied, then it becomes the current line before this command is executed. The spec can be one of the following characters; the default is `z+.`

         .------.-----------------------------------------------------.
         | SPEC | OUTPUT STYLE                                        |
         |------|-----------------------------------------------------|
         |  -   | Place the current line at the bottom of the window. |
         |------|-----------------------------------------------------|
         |  +   | Place the current line at the top of the window.    |
         |      | Upon completion of this command, the last line      |
         |      | output will become the current line.                |
         |------|-----------------------------------------------------|
         |  ^   | Jump back 2 windows' worth of lines, and then do    |
         |      | the equivalent of z+.  Note that z+ is like paging  |
         |      | forward and z^ is like paging backward.             |
         |------|-----------------------------------------------------|
         |  .   | Place the current line in the middle of the window. |
         |      | Upon completion of this command, the last line      |
         |      | output will become the current line.                |
         |------|-----------------------------------------------------|
         |  =   | Place the current line in the middle of the window, |
         |      | and surround it with lines containing hyphens.      |
         ^------^-----------------------------------------------------^

range =
  The `:=` command displays the line number of the current line, or the addressed line if given one address. If given a range of addresses, it tells you the line numbers of the two endpoints and the total number of lines in the range.

## 4.8 Tags

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ta[g][!]          | [tag]                             |
    |       | stac[k]           |                                   |
    |       | po[p][!]          |                                   |
    |       | pus[h][!]         | [+line] [file]                    |
    |       | br[owse][!]       | restrictions                      |
    ^-------^-------------------^-----------------------------------^

Tags provide a way to associate names with certain places within certain files. Typically, you will run the ctags program to create a file named "tags" which describes the location of each function and macro used in the source code for your project. The tag names are the same as the function names, in this case.

In HTML mode, Elvis uses the tags commands to follow hypertext links, but we'll generally ignore that in the following discussions.

ta[g]`[`!`]` `[`tag`]`
  The `:tag` command performs tag lookup. It reads the "tags" file to locate the named tag. It then loads the source file where that tag is defined, and moves the cursor to the specific point within that buffer where the tag is defined. Elvis' implementation of `:tag` also allows you to give extra restrictions and hints. There is also a :stag command which creates a new window and moves its cursor to the tag's definition point.
pus[h]`[`!`]` `[`+line`]` `[`file`]`
  The `:push` command is similar to :edit, except that `:push` saves the cursor position first. Specifically, invoking "`:push`" with no arguments pushes the cursor position onto the tag stack -- nothing else. Invoking "`:push` file" will push the cursor position and then switch to a new file.
br[owse]`[`!`]` restrictions
  The `:browse` command extracts selected tags from the tags file, constructs an HTML document listing those tags (with hypertext links to their definition points inside your source code) and displays it in the current window. There is also a :sbrowse command which displays the same list in a new window. If invoked with no args, they browse all tags in the current file. If invoked with a '!' suffix, they browse `all` tags. See chapter 14. Tags for a full description of restrictions and hints, and browsing.
stac[k]
  Before moving the cursor, Elvis will save the old cursor position on a stack. You can use the `:stack` command to display the contents of that stack. Each window has an independent stack.
po[p]`[`!`]`
  The `:pop` command pops a cursor position off the stack, restoring the cursor to its previous position. When you're browsing though source code, you will typically use `:tag` to go deeper into the call tree, and `:pop` to come back out again.

  In HTML mode, these all work the same except that `:tag` expects to be given an URL instead of a tag name. URLs don't depend on having a "tags" file, so the "tags" file is ignored when in HTML mode. For more information, see the discussion of the <a ...> tag in the Display Modes chapter. The following example would move the cursor to the start of this section:

          :tag elvisopt.html#TAGS

## 4.9 File I/O commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | line  | r[ead]            | file | !shellcmd                  |
    | range | w[rite][!]        | [file | >>file | !shellcmd]       |
    | range | lp[r][!]          | [file | >>file | !shellcmd]       |
    ^-------^-------------------^-----------------------------------^

line r[ead] file `|` !shellcmd
  The `:read` command reads a file or external program, and inserts the new text into the edit buffer after the addressed line. If you don't explicitly give a line address, then the text will be inserted after the current line. To insert the file's contents into the top of the buffer (before line 1), you should specify line 0. For example, to insert the contents of "foo.txt" before line 1, you would give the command...

          :0 read foo.txt

range w[rite]`[`!`]` `[`file `|` >>file `|` !shellcmd`]`
  The `:write` command writes either the entire edit buffer (if no address range is given) or a part of it (if a range is given) out to either a file or an external filter program. If you don't specify the output file or external command, then Elvis will assume it should write to the file that the buffer was originally loaded from.

  Elvis will normally prevent you from overwriting existing files. (The exact details of this protection depend on the edited, filename, newfile, readonly, and writeany options.) If you want to force Elvis to overwrite an existing file, you can append a "!" to the end of the command name, but before the file name. In order to avoid ambiguity, there must not be any whitespace between the "write" command name and the "!" character when you want to overwrite an existing file. Conversely, when writing to an external program there should be whitespace before the "!" that marks the start of the program's command line. The ">>file" notation tells Elvis to append to "file" instead of overwriting it.

range lp[r]`[`!`]` `[`file `|` >>file `|` !shellcmd`]`
  The `:lpr` command sends text to the printer. It is similar to `:write` except that `:lpr` formats the buffer contents as defined by the bufdisplay option and the printing options. If no output file or external program is specified, then the printer output is sent to the file or external program specified by the lpout option.

## 4.10 The args list, and selecting a file to edit

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ar[gs]            | [file...]                         |
    |       | n[ext][!]         | [file...]                         |
    |       | N[ext][!]         |                                   |
    |       | pre[vious][!]     |                                   |
    |       | rew[ind][!]       |                                   |
    |       | la[st]            |                                   |
    |       | wn[ext][!]        |                                   |
    |       | f[ile]            | [file]                            |
    |       | e[dit][!]         | [+line] [file]                    |
    |       | ex[!]             | [+line] [file]                    |
    |       | vi[sual][!]       | [+line] [file]                    |
    |       | o[pen][!]         | [+line] [file]                    |
    ^-------^-------------------^-----------------------------------^

The "args list" is a list of file names. It provides an easy way to edit a whole series of files, one at a time. Initially, it contains any file names that you named on the command line when you invoked Elvis.

ar[gs] `[`file`...]`
  The `:args` command displays the args list, with the current file name enclosed in brackets. You can also use `:args` to replace the args list with a new set of files; this has no effect on whatever file you're editing at that time, but it will affect any :next commands that you give later.
n[ext]`[`!`]` `[`file`...]`
  The `:next` command switches to the next file in the args list. This means it loads the next file from the args list into an edit buffer, and makes that edit buffer be the current buffer for this window. You can also give a new args list on the `:next` command line; this acts like a `:args` command to set the args list, followed by an argumentless `:next` command to load the next (first) file in that list.
N[ext]`[`!`]`
pre[vious]`[`!`]`
  The `:Next` (with a capital "N") and `:previous` commands are identical to each other. They both move backwards through the args list.
rew[ind]`[`!`]`
la[st]
  The `:rewind` and `:last` commands switch to the first and last files in the args list, respectively.
wn[ext]`[`!`]`
  The `:wnext` command is like a :write command followed by a :next command. It saves any changes made to the current file before switching to the next file. (The autowrite option offers a better alternative.)
f[ile] `[`file`]`
  The `:file` command displays information about the current buffer. It can also be used to change the filename associated with this buffer.
e[dit]`[`!`]` `[`+line`]` `[`file`]`
ex`[`!`]` `[`+line`]` `[`file`]`
  The `:edit` and `:ex` commands are identical to each other. They both switch to a new file, or if no file is named then they reread the current file. This has no effect on the args list.
vi[sual]`[`!`]` `[`+line`]` `[`file`]`
o[pen]`[`!`]` `[`+line`]` `[`file`]`
  The `:visual` and `:open` commands switch to a new file if one is named; otherwise they continue to use the current buffer without reloading it from the original file. These commands have the side-effect of switching the window mode from ex mode to either the normal visual mode or the uglier "open" mode, respectively. "Open" mode allows you to use all of the visual commands, but it only displays a single line (the line that the cursor is on) at the bottom of the screen. The sole advantage that "open" mode has over "visual" mode is that "open" mode doesn't need to know what kind of terminal you're using.

## 4.11 Quitting

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | cl[ose][!]        |                                   |
    |       | q[uit][!]         |                                   |
    |       | wq[uit][!]        | [file]                            |
    |       | x[it][!]          | [file]                            |
    |       | qa[ll][!]         |                                   |
    |       | pres[erve]        |                                   |
    ^-------^-------------------^-----------------------------------^

Except for `:qall,` all of these commands attempt to close the current window without losing any changes. When the last window is closed, Elvis exits. The differences between these commands concern how modified buffers are handled. In the discussions below, it is assumed that tempsession is True and the buffer's retain option is False, which is usually the case.

cl[ose]`[`!`]`
  The `:close` command is the simplest. If the current window is the only window and one or more buffers have been modified but not yet saved, then `:close` will fail; otherwise the current window will be closed. The visual ^Wq command uses this command internally. If the window's buffer was modified, then Elvis will just have a modified buffer lying around, which may or may not be visible in some other window. That's okay. The other quitting commands won't allow you to lose that buffer accidentally. You can make some other window view that buffer by giving that buffer's name in parentheses on an ex command line in that other window.
q[uit]`[`!`]`
  The `:quit` command fails if the current buffer has been modified. If you wish to abandon the changes made to the current buffer, you can add a "!" to the end of the command name; this has the effect of turning off the buffer's modified flag.
x[it]`[`!`]` `[`file`]`
  The `:xit` command saves the file if it has been modified, and then closes the window. The visual ZZ command uses this command internally.
wq[uit]`[`!`]` `[`file`]`
  The `:wquit` command saves the file regardless of whether it has been modified, and then closes the window.
qa[ll]`[`!`]`
  The `:qall` command tries to close all of the windows at once. It is equivalent to giving the `:quit` command in each window.
pre[serve]
  The `:preserve` command closes all windows and exits, but it doesn't delete the session file. You can restart the same edit session later by giving the command...

      	elvis -ssessionfile

  ...where sessionfile is the name of the session file, usually "/var/tmp/elvis1.ses". You may want to check the value of the session option first, just to make sure.

## 4.12 Scripts and macros

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | @                 | cutbuf                            |
    |       | so[urce][!]       | file                              |
    |       | safel[y]          | excmds                            |
    |       | al[ias][!]        | [name [excmds]]                   |
    |       | unal[ias][!]      | name                              |
    ^-------^-------------------^-----------------------------------^

@ cutbuf
  The `:@` command executes the contents of a cut buffer as a series of ex command lines.
so[urce]`[`!`]` file
  The `:source` command reads a file, and executes its contents as a series of ex commands. Normally, Elvis would issue an error message if the requested file didn't exist but when a "!" is appended to the command name, Elvis will silently ignore the command if it doesn't exist.
safel[y]`[`!`]` excmds
  The `:safely` executes its arguments as an ex command line. While the argument commands are running, the security option is temporarily set to "safer" so most dangerous commands (security holes) are blocked. In particular, "`:safely source` filename" is a good way to run untrusted scripts.
al[ias]`[`!`]` `[`name `[`excmds`]]`
  The `:alias` command manipulates the alias list. (See the Tips section of the manual for a discussion of aliases.) With no arguments, `:alias` lists all user-defined aliases, and `:alias!` lists all system-defined aliases.

  When given a name but no commands, `:alias` displays the complete definition of the named alias.

  When given a name and commands, `:alias` defines (or redefines) an alias. Adding a "!" suffix (`:alias!`) will cause the alias to be marked as a system alias, which is only significant because the :mkexrc command doesn't save system aliases.

unal[ias] name
  The `:unalias` command deletes the alias with a given name.

## 4.13 Working with a compiler

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | cc[!]             | [args]                            |
    |       | mak[e][!]         | [args]                            |
    |       | er[rlist][!]      | [file]                            |
    ^-------^-------------------^-----------------------------------^

If you use Elvis to edit source code for programs, then you can have Elvis read the output of your compiler and parse that output for error messages. When Elvis finds an error message, it can move the cursor to the file and line number where the error was reported.

To parse the compiler output, Elvis first breaks the output into lines. Each line is then broken into words. If a word looks like a number, then it is assumed to be a line number. If a word looks like the name of an existing file, then it is assumed to be a file name. Any line which contains both a line number and a file name is treated as an error report (with the remainder of the line serving as a description of the error); lines which don't have both of these are simply ignored.

cc`[`!`]` `[`args`]`
mak[e]`[`!`]` `[`args`]`
  The `:cc` and `:make` commands use the ccprg and makeprg options, respectively, to run your compiler or "make" utility, and collect the output. Elvis will then move the cursor to where the first error was detected. (If there were no errors, Elvis will say so and leave the cursor unchanged.)
er[rlist]`[`!`]` `[`file`]`
  After that, the `:errlist` command can be used repeatedly to move to each successive error. You can also use the `:errlist` command with a file name argument to load a new batch of error messages from a file; the cursor is then moved to the first error in that batch.

## 4.14 Built-in calculator

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ca[lculate]       | expr                              |
    |       | ev[al]            | expr                              |
    ^-------^-------------------^-----------------------------------^

Elvis has a built-in calculator which uses a C-like syntax. It is described in section 12: Arithmetic Expressions. The :if, :while, :switch, and :let commands also use the calculator.

ca[lculate] expr
  The `:calculate` command evaluates an expression and displays the result.
ev[al] expr
  The `:eval` command evaluates an expression using the simpler syntax (which basically means that text outside of parentheses is left alone), and then executes the result as an ex command line. This provides a way to use expressions with commands which would not ordinarily use expressions. For example, the following command line inserts the value the elvispath option into the current edit buffer.

      	:eval insert elvispath=(elvispath)

  Note: There is a hardcoded limit of (normally) 1023 characters for the result of any expression. This limit will sometimes impact the use of :eval. For example, if your `$EXINIT` environment variable is longer than 1023 characters then Elvis will be unable to interpret it during initialization.

## 4.15 Buffer commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | al[l][!]          | excmds                            |
    |       | b[uffer][!]       | [buffer]                          |
    |       | (                 | buffer                            |
    |       | bb[rowse][!]      |                                   |
    |       | sbb[rowse][!]     |                                   |
    ^-------^-------------------^-----------------------------------^

al[l]`[`!`]` excmds
  The `:all` command applies a given ex command line to each edit buffer in turn. Normally the command is applied just to the user edit buffers, but if you append a "!" to the command name, then the ex command line is applied to internal buffers as well. For example, the following sets the "bufdisplay" option of all user edit buffers:

      	:all set bufdisplay=normal

  In script files, you can supply multiple command lines to a single `:all` commands by placing a '{' character on the `:all` line, following that with any number of command lines, and then finally a '}' character on a line by itself to mark the end. This notation doesn't allow nesting; you can't use {...} inside a larger {...} command list. (Hopefully this limitation will be lifted soon.)

b[uffer]`[`!`]` `[`buffer`]`
  The `:buffer` command lists either all user edit buffers, or (when "!" is appended to the command name) all buffers including internal ones. If the buffer is being edited in one or more windows, then the window ID is also displayed. Buffers which have been modified will be marked with an asterisk.

  You can also use the `:buffer` command to make the current window display a different buffer.

( buffer
  The `:(`buffer notation causes the current window to display the named buffer, instead of the current buffer. This isn't really a command; it is part of an address. Whenever you give an address without specifying a command, Elvis moves the cursor to the addressed line. In this particular case, we're addressing the most recently changed line of a given buffer, so that's where the cursor is moved to. For more information, see the discussion of Buffer IDs earlier in this chapter (in the discussion of addresses).
bb[rowse]
sbb[rowse]
  The `:bbrowse` and `:sbbrowse` commands create an HTML document which lists the names of all user buffers (or, when a '!' is appended to the command name, all buffers including internal buffers). You can then go to one of the buffers just by following the hypertext link. The difference between these two commands is that `:bbrowse` displays the list in the current window, but `:sbbrowse` creates a new window to display it.

## 4.16 Window commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | sp[lit]           | [+line] [file | !shellcmd]        |
    |       | new               |                                   |
    |       | on[ly]            |                                   |
    |       | sne[w]            |                                   |
    |       | sn[ext]           | [file...]                         |
    |       | sN[ext]           |                                   |
    |       | sre[wind]         |                                   |
    |       | sl[ast]           |                                   |
    |       | sta[g]            | [tag]                             |
    |       | sb[rowse]         | restrictions                      |
    |       | sa[ll]            |                                   |
    |       | wi[ndow]          | [ +[+] | -[-] | number | buffer]  |
    |       | di[splay]         | [modename [language]]             |
    ^-------^-------------------^-----------------------------------^

sp[lit] `[`+line`]` `[`file `|` !shellcmd`]`
  The `:split` command creates a new window. If you supply a file name, then it will load that file into an edit buffer and the new window will show that buffer. If you supply a shell command line preceded by a '!' character, then it will create an untitled buffer, and read the output of that command line into the buffer. Otherwise, the new window will show the same buffer as the current window.
new
sne[w]
  The `:new` and `:snew` commands are identical to each other. They both create a new empty buffer, and then create a new window to show that buffer.
on[ly]
  Close all windows except the current one. (To close only the current window, use the :close command.)
sn[ext] `[`file`...]`
sN[ext]
sre[wind]`[`!`]`
sl[ast]
sta[g] `[`tag`]`
sb[rowse] restrictions
  The `:snext, :sNext, :srewind, :slast, :stag,` and `:sbrowse` commands resemble the :next, :Next, :rewind, :last, :tag, and :browse commands, respectively, except that these "s" versions create a new window for the newly loaded file, and leave the current window unchanged.
sa[ll]
  The `:sall` command creates a new window for any files named in the args list, which don't already have a window. (See section 4.10: The args list... for a discussion of the args list.)
wi[ndow] `[`+ `|` ++ `|` - `|` -- `|` number `|` buffer `]`
  The `:window` command either lists all windows (when invoked with no arguments) or switches to a given window. You can specify which to switch to by giving one of the following arguments.

          .----------.-----------------------------------------------.
          | ARGUMENT | MEANING                                       |
          |----------|-----------------------------------------------|
          |    +     | Switch to the next window, like ^Wk           |
          |    ++    | Switch to the next window, wrapping like ^W^W |
          |    -     | Switch to the previous window, like ^Wj       |
          |    --    | Switch to the previous window, wrapping       |
          |  number  | Switch to the window whose windowid=number    |
          |  buffer  | Switch to the window editing the named buffer |
          ^----------^-----------------------------------------------^

di[splay] `[`modename `[`language`]``]`
  The `:display` command switches the window to a new display mode, overriding the value of the bufdisplay option. The display option indicates the current display mode. If you omit the new modename, then the `:display` command will list all supported display modes, with an asterisk next to the current mode. The "syntax" mode allows you to specify which language's syntax it is supposed to use; if you don't specify a language, Elvis will guess the language from the file name's extension.

## 4.17 Configuration

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ab[breviate][!]   | [lhs rhs]                         |
    |       | una[bbreviate][!] | lhs                               |
    |       | map[!]            | [flags] [lhs [flags] rhs]         |
    |       | unm[ap][!]        | [flags] lhs                       |
    |       | bre[ak][!]        | [flags] lhs                       |
    |       | unb[reak][!]      | [flags] lhs                       |
    |       | dig[raph][!]      | [lhs [rhs]]                       |
    |       | col[or][!]        | [face [attributes]]               |
    |       | gu[i]             | text                              |
    |       | se[t][!]          | [option=value | option? | all]    |
    |       | lo[cal]           | [option=value | option ]          |
    |       | le[t][!]          | option=expr                       |
    |       | if                | expr                              |
    |       | th[en]            | excmds                            |
    |       | el[se]            | excmds                            |
    |       | try               | excmds                            |
    |       | wh[ile]           | expr                              |
    |       | do[loop]          | excmds                            |
    |       | for[each]         | option ["in"] expression          |
    |       | sw[itch]          | expr                              |
    |       | cas[e]            | value [excmds]                    |
    |       | def[ault]         | excmds                            |
    |       | mk[exrc][!]       | [file]                            |
    ^-------^-------------------^-----------------------------------^

ab[breviate]`[`!`]` `[`lhs rhs`]`
una[bbreviate]`[`!`]` lhs
  The `:abbreviate` and `:unabbreviate` commands add and remove entries to the abbreviation table, respectively. Also, the `:abbreviate` command can be used with no arguments to list the current contents of the abbreviation table. For a discussion of abbreviations, see section 3.3: Abbreviations. Normal abbreviations are only active while you're typing in a normal text buffer; adding a '!' suffix to the command name causes the macro to be active while you're entering ex command lines.
map`[`!`]` `[`flags`] [`all `|` lhs `[`flags`]` rhs`]`
unm[ap]`[`!`]` `[`flags`]` lhs
  The `:map` and `:unmap` commands add and remove entries to the map table, respectively.

  When the `:map` command is given without any text to map, it lists the contents of a map table, excluding cursor keys. When invoked with the word "all" instead of text to map, it lists all entries from the map table including cursor keys.

  The primary purpose of the map table is to assign actions to the cursor keypad and the function keys. Each of these keys sends an arbitrary but distinctive sequence of characters when pressed. The map tables are used to convert these arbitrary character sequences into command keystrokes that Elvis can do something useful with. For example, arrow keys are normally mapped to the h, j, k, and l commands.

  The first text argument to `:map` is the raw character sequence sent by a key. This can be either a literal sequence of characters, or a gui-dependent symbol representing a particular keystroke. See the User Interfaces chapter for lists of keystrokes. Also, function keys can usually be denoted by #1 for the <F1> key, #2 for the <F2> key, and so on.

  The second text argument is character sequence that Elvis should pretend you typed whenever the raw characters are received.

  Elvis allows you to use symbolic names for some keys and characters. The following symbols represent individual characters, and are case-insensitive: <Nul>, <BS>, <Tab>, <FF>, <NL>, <LF>, <EOL>, <CR>, <Return>, <Enter>, <Esc>, <CSI>, <Del>, <Nul>, <Space>, <lt>, <gt>, <Bar>, and <Bslash>

  In addition, each user interface may add its own symbols for cursor keys and function keys. The exact list of symbols will vary. Typically, these names will be case-sensitive. See the X11 Keys, Windows Keys, and Termcap Keys manual sections.

  Flags may precede either argument. Some flags select the context in which the map applies, and some affect the way the second argument's text is used.

      .----------.------------------------------------------------------.
      |  FLAG    | WHAT IT MEANS                                        |
      |----------|------------------------------------------------------|
      | command  | works in the normal "Command" mode                   |
      | motion   | works when used as the target of an operator         |
      | select   | works while text is selected via V, v, or ^V         |
      | input    | works in "Input" or "Replace" mode on main buffer    |
      | history  | works when typing an ex command or search expression |
      | mode=name| works only if the mapmode option is set to name      |
      | visual   | always interpret second argument text as vi commands |
      | noremap  | never check second text for maps, regardless of remap|
      | nosave   | prevent mkexrc from saving this map                  |
      ^----------^------------------------------------------------------^

  Using `:map!` (with a "!") causes Elvis to act as though you used the "input" and "history" context flags. If you don't use any context flags or "!", then Elvis will assume you want "command", "motion", and "select" contexts. Using "visual" implies "input" and "history", unless you explicitly supply at least one of those context flags.

  You can use contexts with a `:map` command that has no text arguments to selectively list only those maps which work in that context. You can also use contexts with `:unmap` to selectively delete maps in a given context.

bre[ak]`[`!`]` `[`flags`]` lhs
unb[reak]`[`!`]` `[`flags`]` lhs
  The `:break` and `:unbreak` commands set and reset the breakpoint flag for a given macro, respectively. Using a '!' suffix causes the breakpoint to be set for an input-mode map. This is used for debugging macros, as described in section 16.3: How to debug macros. If a macro has its breakpoint flag set, and the maptrace option is set to run, then when that map is encountered Elvis will automatically switch maptrace to step mode.

  NOTE: The flags are the sames as those used by :map, above, but `:break` and `:unbreak` only partially support them. This is because each entry in the map table may apply to multiple contexts, but only has a single "break" flag. So when you set or clear a break point in one context, it may also affect other contexts. Usually this isn't a problem.

dig[raph]`[`!`]` `[`lhs `[`rhs`]``]`
  The `:digraph` command manipulates the digraph table. (See section 3.2: Digraphs for a discussion on digraphs.) With no arguments, it lists the digraph table. With one argument, it removes the given digraph from the table. With two arguments, it adds the given digraph to the table, or if the same two ASCII characters are already in the table then it alters the existing entry.

  Normally, the `:digraph` command sets the most significant bit in the last argument's character. That way you don't need to be able to type a non-ASCII character on your keyboard in order to enter it into the table; you can type the ASCII equivalent and allow Elvis to convert it to non-ASCII before storing the digraph. If you don't want Elvis to set the most significant bit, then append a "!" to the end of the command name.

col[or]`[`!`]` `[`face `[`attributes`]``]`
  The `:color` command is used for configuring the colors and other attributes of text. If invoked without arguments, then it lists any colors/attributes you've set (or for all faces if invoked with a ! suffix). If invoked with the name of a face (see below) then it lists the colors/attributes for that single face. If invoked with both a face name and new colors/attributes then it changes the colors/attributes for that face.

  The list of possible face names is not entirely preset. Different display modes can be configured to use totally new faces for any purpose. A few of the faces are built into Elvis, and several more are used in the syntax and markup descriptions included in the standard Elvis distribution. These are:

      .------------.--------------.--------------------------------------.
      | FACE NAME  | INHERIT FROM | USED FOR                             |
      |------------^--------------^--------------------------------------|
      |In all display modes and all user interfaces...                   |
      | normal     | --           | default when window has input focus  |
      | idle       | normal       | default when window loses input focus|
      | bottom     | --           | ex commands at the bottom of a window|
      | lnum       | (normal/idle)| line numbers for :set number         |
      | showmode   | (normal/idle)| input mode name for :set showmode    |
      | ruler      | (normal/idle)| line/column numbers for :set ruler   |
      | selection  | --           | selected text for v, V, and ^V cmds  |
      | hlsearch   | --           | matching text for the hlsearch option|
      | hlobjectn  | --           | highlighting via hlobject & hllayers |
      | spell      | --           | highlighting via spell-checking      |
      | fold       | --           | regions folded via the :fold command |
      | header     | --           | page headers if lpheader is set      |
      |------------^--------------^--------------------------------------|
      |In the "syntax" display modes...                                  |
      | comment    | (normal/idle)| comments                             |
      | string     | (normal/idle)| string literals                      |
      | char       | string       | character literals                   |
      | regexp     | string       | regular expression literals          |
      | regsub     | regsub       | substitution text after regexp       |
      | number     | (normal/idle)| number literals                      |
      | keyword    | (normal/idle)| keywords                             |
      | other      | keyword      | names matching "other" keyword descr.|
      | function   | (normal/idle)| names which appear to be functions   |
      | variable   | (normal/idle)| any other name                       |
      | prep       | (normal/idle)| preprocessor directives              |
      | prepquote  | (normal/idle)| filenames in preprocessor directives |
      | doc        | (normal/idle)| embedded documentation               |
      | docmarkup  | doc          | markup lines in embedded docs        |
      | docindent  | doc          | embedded doc lines that are indented |
      | kindk      | (normal/idle)| tags with "kind=k" if tagkind is set |
      | libk       | (normal/idle)| library tags w/"kind=k" if taglibrary|
      |------------^--------------^--------------------------------------|
      | In "normal" and "syntax" display modes...                        |
      | specialkey | (normal/idle)| control characters if list is on     |
      | nontext    | specialkey   | end-of-line marker if list is on     |
      | extends    | specialkey   | side-scrolling arrows if wrap is off |
      |------------^--------------^--------------------------------------|
      |In the "hex" display mode...                                      |
      | hexheading | (normal/idle)| headings in the hex display mode     |
      | hexoffset  | (normal/idle)| offsets, at the start of each line   |
      | hexcursor  | (normal/idle)| hex code for character at cursor     |
      |------------^--------------^--------------------------------------|
      |In the "html", "man", and "tex" display modes...                  |
      | formatted  | (normal/idle)| normal text in markup display modes  |
      | bold       | formatted    | boldface text                        |
      | italic     | formatted    | italic text                          |
      | underlined | formatted    | underlined text                      |
      | fixed      | formatted    | fixed-pitch text                     |
      | link       | formatted    | HTML hypertext reference             |
      | definition | bold         | definition of a term within text     |
      | graphic    | fixed        | line-drawing chars for <pre graphic> |
      | bullet     | (normal/idle)| bullets in unordered list, like <ul> |
      | markup     | (normal/idle)| markups revealed by list/showmarkups |
      | form       | (normal/idle)| common attributes of form inputs     |
      | form_button| form         | buttons such as "Submit"             |
      | form_radio | form         | values of radio buttons              |
      | form_check | form         | checkbox                             |
      | form_text  | form         | text input fields, including textarea|
      | form_other | form         | other form inputs                    |
      |------------^--------------^--------------------------------------|
      |In the "x11" user interface...                                    |
      | cursor     | --           | cursor color                         |
      | tool       | --           | toolbar buttons                      |
      | toolbar    | --           | toolbar & labels of disabled buttons |
      | scroll     | tool         | scrollbar buttons (background only)  |
      | scrollbar  | toolbar      | scrollbar background                 |
      | status     | tool         | text boxes at statusbar's right edge |
      | statusbar  | toolbar      | status bar & text on its left edge   |
      ^------------^--------------^--------------------------------------^

  The "normal" and "idle" distinction is made so that you can configure Elvis to display the current window differently than other windows. For example, "`:color idle on gray80`" in the x11 user interface will cause idle windows to be displayed with a dull background color, while the current window is displayed with the normal background color.

  Normally, the new attributes you specify will completely replace the face's existing attributes. However, you can add or subtract the new attributes from the face's existing attributes by placing "`+=`" or "`-=`" at the front of the attribute string. Also, when using the "`-=`" notation you can simply say "`color`" instead of the face's real color; this will remove any existing color. For example...

      	:color hlsearch += red

  ... will cause hlsearch text to be red (in addition to any other attributes -- usually bold), and...

      	:color hlsearch -= color

  ... will remove that coloration, but keep the bold attribute.

  The `:color` command allows you to specify other attributes besides color. You can specify which font it should inherit any unspecified colors or attributes from, via a "like" clause. You can also give attributes such as "underlined". The complete list of attributes includes:

  color | The foreground color. If you don't specify a foreground color, then the inherited foreground color is used. The exact list of acceptable colors will vary, depending on your hardware and the user interface. For X-windows, you can use any of the standard color names such as black, royal blue, or #800028. For the termcap interface and most others, the list includes black, red, green, brown, blue, magenta, cyan, white, gray, light red, light green, yellow, light blue, light magenta, light cyan, and bright white... with the caveat that the "bold" attribute may interact strangely with the "light" or "bright" colors. There is also default color, but not all ANSI-ish terminals implement it correctly, so use it with caution.
  or color | An alternate foreground color. Elvis will choose the foreground color which gives the highest contrast against the normal background color. (If no background color has been set, then the background option may affect the choice.) Elvis also remembers the color which had the highest contrast with white, for use when printing whenever the lpcolor option is set.
  on color | The background color. If you don't specify a background color, then the inherited background color is used. The list of color names also varies, just as it does for foreground colors. For most user interfaces, the list of background colors is identical to the list of foreground colors, but the termcap interface limits you to the first 8 colors (black through white in the above list). The x11 interface has experimental support for images for some backgrounds. For example, "color normal on blue sand.xpm" will load the "sand.xpm" image, tint it blue, and use that as the background for normal text. See the X11 Background Images discussion for more information. The termcap interface also has experimental support for a transparent background color, which resets the background to its default (whatever that happens to be). You can also use default, which tries to achieve the same effect in a slightly different way. If you use this feature, then you should probably set the background option.
  like otherface | All faces ultimately inherit from either "normal" or "idle", depending whether the window has input focus or not. This attribute allows you to add another font in the inheritance chain between this font and "normal" or "idle". For example, "`:color char like string`" causes character literals to be displayed using the same colors and attributes as string literals.
  bold underlined italic boxed | These are all attributes that can be attached to a face. Any inherited attributes are retained; these keywords only allow you to add new attributes to the inherited ones. For example, ":color x underlined|color y like x bold", will cause the "y" font to be both bold and underlined. Some user interfaces may not be able to display all of these attributes. And even if the user interface can display them all individually, it may not be able to display all possible combinations. The boxed attribute attempts to draw a box around the text; for some user interfaces, or when printing to some types of printers, the box may be implemented by changing the background. In the termcap user interface, it uses the standout attribute.
  graphic | This is a special attribute. It causes some characters to be converted to line-drawing characters. This is used for implementing the <pre graphic> tag in HTML.
  fixed proportional | On your screen these attributes have no effect, but when printing via the :lpr command they may select between fixed-pitch and variable-pitch fonts. Some lptype settings don't support this, and among those that do, some support it better than others. Printing with proportional fonts is a little quirky because Elvis' text formatting was designed to support only fixed-pitch fonts. The "epson", "pana", "ibm", and "hp" lptypes support proportional printing, but are unable to make columns line up correctly when you use it. Because proportional text tends to be narrower than fixed-pitch text, you may want to increase lpcolumns from 80 to about 110, if your document consists mostly of proportional text. The "ps", "ps2", and "windows" lptypes handle proportional text in a different way. In order to prevent overlaps or large gaps when mixing fonts on a line, these drivers adjust the width of each chunk of proportional text to match the width it would have had if it was fixed-pitch. For large chunks you'll probably never notice, but if you have a single word in a proportional font, and most of the letters in that word happen to be narrow, then the stretching may be significant.

gu[i] text
  The `:gui` command provides a way to pass unusual commands to the user interface. Currently, the only user interface which uses this is the "x11" interface, which uses it mostly to configure the toolbar.
se[t]`[`!`]` `[`option=value`... |` option?`... |` all `|` everything`]`
  The `:set` command allows you to examine or change the values of options.

  With no arguments, `:set` lists the names and values of any options that have been altered or are of frequent interest. If given the argument "all" it will list the names and values of most (but not really all) options. If given the argument "everything", it really will list all options. If given the name of an option followed by a "?" character, `:set` will output the option's name and value. If given the name of a group of options, followed by a "?" character, `:set` will output the names and values of all options in that group.

  To turn a Boolean option on, just give the name of the option. You can turn it off by adding the prefix "no" to the option name, and you can negate it by adding the "neg" prefix to its name.

  To change the value of a non-Boolean option, give the name followed immediately by an "=" and the new value. If the new value contains whitespace, you should either enclose the entire value in quotes, or precede each whitespace character with a backslash.

  If you give the name of a non-Boolean option, without either "=value" or "?", then Elvis will display its value.

      .-----------.----------------------------------------------------.
      | EXAMPLE   | WHAT IT DOES                                       |
      |-----------|----------------------------------------------------|
      | :set      | display names & values of changed/important options|
      | :set all  | display names & values of most POSIX-compliant opts|
      | :set ts?  | display name & value of the tabstop option         |
      | :set lp?  | display names & values of all printing options     |
      | :set ts=4 | set value of the tabstop option to 4               |
      | :set ai   | turn on the autoindent option                      |
      | :set noai | turn off the autoindent option                     |
      | :set negai| toggle the autoindent option                       |
      ^-----------^----------------------------------------------------^

  Adding a "!" to the end of the command name (`:set!`) affects the behavior in two ways. First, it causes any displayed options to be shown with the short name, and the name of their group. For example, "`:set! tabstop`" shows "buf.ts=8".

  The other difference is that `:set!` changes the option's default value in addition to its current value, and then marks the option as having not been changed. This is used mostly in Elvis' initialization scripts.

lo[cal] option=value`... |` option`...`
  The `:local` command is similar to :set, and is intended to be used in aliases and scripts. In addition to setting options' values, it also pushes the old values onto a stack; the old values are automatically restored at the end of the alias or script. Another difference is that where `:set` would output an option, `:local` merely pushes its old value, without outputting or changing the option's value. This means that you can save a non-Boolean option simply by mentioning its name on a `:local` command line; Boolean options can also be saved without altering them, but you must put a question mark after the option's name.

  Here's a simple alias which uses `:local`. It adds up the numbers in all lines from the current line forward to the next line which contains the "total:", and stores the sum in the "total:" line.

          :alias total {
              local nowrapscan ignorecase t=0
              .,/total:/-1 s/\d\+/let t=t+&/x
              eval /total:/ s/total:.*/total: (t)/
          }

le[t]`[`!`]` option `[`oper`]`= expr
le[t]`[`!`]` option =~ excmds
  Both forms of the `:let` command compute a new value for an option. The "= expr" (or "oper= expr") form evaluates an expression to produce the new value. The oper, if used, can be any of the expression operators, and must be followed immediately by the "=", without any intervening whitespace. As in C, using an operator in this way causes the assigned option to be treated as the left-hand operand for the operator, and the rest of the expression as the right-hand operand.

          :let a = 2+2
          :calc a
          4
          :let a <<= 3
          :calc a
          32

  Note that even Boolean options use the "=" notation here. You can not say ":let nowrap" to turn off the wrap option, for example.

  The "=~ excmds" form is only available if Elvis is compiled with FEATURE_EQUALTILDE defined (i.e., if `:calc feature("equaltilde")` returns `True`). This form stores the option's old value into a buffer, applies the excmds to that buffer, and then copies the resulting buffer back into the option. This is most useful when used with the :s command. For example, the following capitalizes the first letter of each word in "a".

          :let a =~ s/\<\w/\u&/g

  If Elvis is compiled with array support (that is, if `:calc feature("array")` says `True`) then you can also use a subscript after the option name, to change just part of its value. For more information about subscripts, see the discussion in the Arithmetic Expressions chapter.

  When invoked as `:let!` (with a '!' suffix), Elvis will set both the current and default values of the option, and mark the option has having not been changed. This is used in some of Elvis' initialization scripts.

if expr
th[en] excmds
el[se] excmds
  The `:if` command evaluates an expression, and sets an internal variable according to whether the result was true or false. Later, the `:then` and `:else` commands can be used to test that variable, and conditionally execute other ex commands.

  Note that after an `:if` command, any other ex commands which don't start with `:then` or `:else` will be executed unconditionally.

  In aliases or script files, you can supply multiple command lines to a single `:then` or `:else` by placing a '{' character on the `:then/:else` line, following that with any number of command lines, and then finally a '}' character on a line by itself to mark the end. The following example demonstrates this syntax, and also shows that you can safely use `:if` inside a `:then` or `:else` command:

      	:if i <= 0
      	:then {
      		if i == 0
      		then echo zero
      		else echo negative
      	}
      	:else echo positive

try excmds
  The `:try` command executes its argument text as an ex command line. Regardless of whether that command line succeeds or fails, the `:try` command itself always succeeds. That's significant because when a command fails, all pending aliases, macros, and scripts are canceled; `:try` prevents that. Error messages and warning messages are disabled while the command line runs. Afterward, the then/else is set to indicate whether the command line succeeded. This command is useful for implementing specialized error handing in an alias or script. The following example will search for "foo"; if there is no "foo" then it will search for "bar":

          :try /foo
          :else /bar

wh[ile] expr
do[loop] excmds
  The `:while` command stores an expression. It should be followed by a `:do` command; the `:do` command repeatedly evaluates the expression, and as long as the result is true it executes the commands which follow the `:do`. The following example counts from 1 to 10:

          :let i=1
          :while i <= 10
          :do {
              calc i
              let i=i+1
          }

for[each] option `[`in`]` files...
for[each] option expression
  The `:foreach` or `:for` command is similar to `:while` in that it sets up information that `:do` uses for looping. The difference is that it sets up different information: A variable name, and a list of values that the variable should take on.

  If the list expression begins with the word "in", then "in" will be stripped off and the remainder will be interpreted as a space-delimited list of file names. You can use `backslash-space` to embed actual spaces in the names. If the file names contain wildcard characters, then they'll be expanded to the actual file names. The body of the loop is executed separately for each matching file name.

          for i in *.h
          do calc i

  Without the word "in", the remaining arguments are evaluated using the normal expression syntax, and the result is then divided into whitespace-delimited words. The body of the loop is executed separately for each word.

          foreach i (1..10)
          do calc i

sw[itch] expr
cas[e] label `[`excmds`]`
def[ault] excmds
  The `:switch` command evaluates an expression and stores the result. The `:case` command compares that result to a given value, and executes an ex command line if it matches. If you omit the command line then it will carry forward to the next `:case` which does have an ex command line; this allows multiple cases to share a single ex command line. The `:default` command executes its ex command line if no previous case was matched. Here's an example:

          :switch os
          :case unix
          :case win32 echo Elvis has graphical and text-mode interfaces.
          :case os2 {
            echo Elvis has been ported natively as a text-mode program.
            echo You can also compile it to use the X11 interface from
            echo Unix, but you need the EMX libraries to run it.
          }
          :case msdos echo Elvis is slow and ugly under DOS.
          :default echo How are you even running this?

  Notice that there is no punctuation after the case value, and that there is no "break" or "endswitch" command. This example says "Elvis has graphical and text mode interfaces" for both the "unix" and "win32" cases; the "unix" case has no command, so it falls through to the "win32" case.

  The `:if/:then/:else`, `:while/:do`, and `:switch/:case/:default` command structures all permit nesting. I.e., the commands in a `:then` command can't affect the "if" variable to cause the `:else` command to also be executed.

mk[exrc]`[`!`]` `[`file`]`
  The `:mkexrc` command creates a file containing ex commands which recreate most of configuration features of Elvis, including:
  - the map table
  - the abbreviation table
  - the digraph table
  - the autocmd tables
  - custom spell-checker words
  - any options which have been set

  If invoked with a filename, then the mkexrcfile option will be set to that name; this setting will be stored in the script, along with your other settings. If the named file already exists, then you must use `:mkexrc!` (with a "!" suffix) to overwrite it.

  If you don't specify a filename, then it will write to the file whose name is already stored in the mkexrcfile option. If that file already exists, then `:mkexrc` will overwrite the file without requiring a "!" suffix.

  If mkexrcfile hasn't been set, and you don't specify a name on the command line, then `:mkexrc` will act as though you invoked it with a default name -- either ".elvisrc" or "elvis.rc" in the home directory, depending on the operating system. Elvis' default initialization will :source that file, so you don't need to explicitly `:source` it yourself each time you start Elvis. That's convenient.

  In summary: The first time you run `:mkexrc` without arguments, it will store the configuration in a standard place. After that, when you invoke `:mkexrc` without arguments, it will overwrite the previous configuration file. You can also explicitly make it write the configuration out to some other file if you want to.

## 4.18 Auto commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | aue[vent][!]      | [event] ...                       |
    |       | aug[roup][!]      | [group]                           |
    |       | au[tocmd][!]      | [group] [events [file [excmd]]]   |
    |       | doa[utocmd]       | [group] event [file]              |
    ^-------^-------------------^-----------------------------------^

These commands only exist if the `FEATURE_AUTOCMD` feature was enabled when Elvis was compiled. (The command `:calc feature("autocmd")' should return `True`.)

This is vim's way to run commands automatically in certain situations. See the discussion in the Tips chapter. It is sort of like Elvis' elvis.arf file and related files, but much more versatile. I'm trying to add it to Elvis to gain that versatility. It is extremely complex, though, so you should expect to be baffled as you read the following...

aue[vent]`[`!`]` `[`event`] ...`
  This lets you create new event types (as additions to the built-in list). The events won't be triggered automatically, but you can explicitly trigger them via the :doautocmd command. For example, the following commands create a new event named "BufAdd", and arrange for it to behave mostly as a synonym for the built-in BufCreate event.

      	:auevent BufAdd
      	:au BufCreate * doau BufAdd

  For a more complex example, the following commands create a new event named "FileChangedRO", arrange for it to be triggered on the first modification that you make to a readonly file, and then use it to give a warning when you start modifying a readonly file:

      	:auevent FileChangedRO
      	:au OptSet modified {
      	  if readonly
      	  then doau FileChangedRO
      	}
      	:au FileChangedRO * message ^GChanging a readonly file!

  Note: Vim doesn't have a `:auevent` command. I added it to Elvis because vim is rapidly acquiring new events, and it seemed easier to add a general solution like this than to try to reimplement all of vim's new events in Elvis.

aug[roup]`[`!`]` `[`group`]`
  Auto commands are divided into groups, for the sake of convenience. The `:augroup` command creates groups, lists them, or selects one for editing. It has no effect on which events get run, though -- it is used purely for editing.

  When invoked without arguments, it lists the current groups.

  When invoked with a group name as an argument, it selects that group as being the one that later :autocmd commands will edit. The default group is named "END", so most sequences of autocmd configuration commands begin with "`:aug` group", contain any number of :au commands, and then end with "`:aug END`".

  You can create your own groups. If the group name that you specify didn't exist before this command, then `:aug` will create it.

  The "!" suffix is used to indicate whether the named group should be saved by the :mkexrc command. Generally, you won't use "!" in your own `:aug` commands. Elvis' standard scripts use "`:aug!`" to set up a standard set of auto commands. You wouldn't want them in your .exrc file, since they're already in the standard scripts.

au[tocmd]`[`!`]` `[`group`]` `[`events `[`file `[`excmd`]``]``]`
  The `:au` command lists, adds, or deletes auto command entries from the current group. The events are described in the Tips chapter.

  The group, events, and file arguments are used to select the event. The group can be any group name that was created by an earlier :augroup command; if omitted, it defaults to the name used in the most recent ":augroup group" command. The events parameter is a comma-delimited list of events as described in the Tips chapter, or "*" for all events; if you omit it (and all parameters after it), it defaults to "*", which is handy when listing files. The file argument is a wildcard pattern such as "*.c"; if you omit it (and all parameters after it), it defaults to "*" so the pattern will work for any files. The excmd is any ex command line, or {...} delimited group of lines; it may access the auevent, aufilename, and auforce options to determine what triggered the event.

  Vim allows the special keyword "nested" to appear at the start of the excmd to indicate that it can be run recursively. Elvis allows the "nested" flag, but ignores it. Elvis never allows auto commands to be recursive.

  Listing: If you don't give either a `!` after the command name (not "`:au!`"), or a new excmd to run, then `:au` will list the matching auto commands. Some examples:

      	:au		list all commands in the current group
      	:au END		list all commands in the default group
      	:au BufRead	list all commands for BufRead events
      	:au * *.html	list all commands for HTML files

  Deleting: With a `!` after the command name ("`:au!`"), then it deletes the matching auto commands, instead of listing them.

      	:au!		delete all commands in the current group
      	:au! END	delete all commands in the default group
      	:au! BufRead	delete all commands for BufRead events
      	:au! * *.html	delete all commands for HTML files

  Adding: To add an entry, use the same arguments with an ex command at then end. The new command will be added to the end of the group. (When multiple commands match a particular event, they're executed from top to bottom in the list, so any existing commands will be executed before the newly added command. The following example adds a rule that makes all HTML files be read-only.

      	:au BufRead *.html set readonly

  Replacing: You can delete old auto commands and then add a new one in a single step, by invoking `:au` with both the `!` suffix and an new excmd to execute. The following example replaces the previous one.

      	:au! BufRead *.html set noreadonly

doa[utocmd] `[`group`]` event `[`file`]`
  This simulates an event, causing the associated auto commands to be run. This is handy for testing your configuration, or for rerunning the commands after you've changed your configuration.

  By default, it runs commands in all groups, but if you specify a group then it will only run auto commands in that group. If there is no such group, it gives an error message.

  The event argument selects the particular event you want to simulate.

  The file, if given, is the matched against the wildcard patterns. If you omit it, then the current file name will be used (as indicated by the filename option); this is usually what you want to do.

  Note: Vim allows this command to be abbreviated to "`:do`", but most users abbreviate it as "`:doau`". That's a good thing, because Elvis already has a :do command, used for looping.

  Note: Vim also has a "`:doautoall`" command. I don't expect to implement that one, since you can achieve the same effect in Elvis by running "`:all doau`".

## 4.19 Folding

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | range | fo[ld][!]         | [name]                            |
    | range | unf[old][!]       | [name]                            |
    ^-------^-------------------^-----------------------------------^

These commands are only available if your version of Elvis was compiled with the folding feature is enabled. (The command ``:calc feature("fold")`' should return True.) "Folding" allows you to temporarily hide portions of your text, without actually deleting it.

Elvis allows you to create named regions called "FOLDs". Each FOLD is either folded or unfolded, and you can toggle a FOLD between those two states at will. Folded regions, no matter how large, are displayed as a single line which shows the FOLD's name. Unfolded regions are displayed exactly like text that isn't in a FOLD. The only reason that Elvis bothers to remember unfolded FOLDs is to allow you to refold it easily.

There are some limitations: You can nest one FOLD inside another, but you can't have overlapping FOLDs, or different folds with exactly the same endpoints. Folding only affects the appearance of the normal and syntax display modes.

You can use the ":color `fold` attributes" command to control the appearance of folded FOLDs.

range fo[ld]`[`!`]` `[`name`]`
range unf[old]`[`!`]` `[`name`]`
  The `:fold` and `:unfold` commands both have a very similar syntax. When invoked with a range of lines and a name, they create a FOLD which is initially either folded or unfolded, respectively. When invoked with either just a range of lines or just a name, they alter the state of any existing FOLDs. The following table shows this in greater detail:

      .--------------------.---------------------------------------------.
      | COMMAND            | WHAT IT DOES                                |
      |--------------------|---------------------------------------------|
      | :range fold name   | Create a folded FOLD with the given name.   |
      | :range fold        | Refold any existing FOLDs which contain     |
      |                    |   lines in the given range.                 |
      | :fold name         | Refold any existing FOLDs which have the    |
      |                    |   given name.                               |
      | :fold              | Refold the FOLD containing the current line.|
      |--------------------|---------------------------------------------|
      | :range unfold name | Create an unfolded FOLD with the given name.|
      | :range unfold      | Unfold any existing FOLDs which contain     |
      |                    |   lines in the given range.                 |
      | :unfold name       | Unfold any existing FOLDs which have the    |
      |                    |   given name.                               |
      | :unfold            | Unfold the FOLD containing the current line.|
      ^--------------------^---------------------------------------------^

  Both commands can accept a "!" modifier. When FOLDs are nested inside each other, the `:fold` and `:unfold` commands normally refold or unfold a single layer; the "!" causes them to refold or unfold all layers. In particular, you can unfold all FOLDs via the following command:

      	:%unfold!

  For both commands, the name argument is evaluated using the simpler expression syntax, with `$1` being replaced by the number of lines in the range. The following shows how this could be used to fold the bodies of C functions and give the folds the same name as their function. (This depends on the show option containing "tag" in it somewhere.)

      	:g/^{/,/^}/fold {(current("tag"))(":" $1 "lines")}

  There are also folded() and unfolded() functions. If the cursor is in a folded FOLD, then the `folded()` function returns its name. Otherwise it returns "" -- even if the cursor is in an unfolded FOLD. The `unfolded()` function does the opposite. This allows you to do things like the following, which toggles folding.

      	:alias negfold {
      		if folded()
      		then unfold
      		else fold
      	}

  Also, see the folding option for a way to enable folding in one window but disable it in another.

## 4.20 Regions

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | range | reg[ion]          | [face [comment]]                  |
    | range | unr[egion]        | [face]                            |
    | range | chr[egion]        | face newface [newcomment]         |
    ^-------^-------------------^-----------------------------------^

These commands are only available if the region feature is enabled. (The command `:calc feature("region")' should say True.)

Regions give you a way to change the appearance of specific lines. Each region has the following attributes:

- a span of lines to which it applies,
- a face to use instead of the "normal" or "idle" face for those lines, and
- an optional comment.

The face names are the same ones that are used with the :color command.

The show option can also contain a "region" word, which causes the current region's comment to be displayed at the bottom of the window. You can use current("region") or current("rcomment") to access the current region's face name or comment, respectively.

All three of these commands act on the current line by default. These are plain old '\n'-delimited lines, by the way -- the same definition of "line" as is used by ex addresses, and the normal and syntax display modes. When you're using any other display mode, the region highlighting may be unreliable.

range reg[ion] `[`face `[`comment`]]`
  This creates a region, or lists existing regions.

  When invoked without a face name, it lists any regions which lie at least partly within the given range of lines. The following command lists all regions in the current buffer:

      	:%reg

  When invoked with a face name and optional comment, it creates a region. If you don't specify a comment, then the face name will serve as the comment. Regions aren't allowed to overlap, so if there were any other regions in the given range before you invoke `:region`, they'll be clobbered. The following comment creates a region that uses the "notes" face, covering the first 10 lines of the file:

      	:1,10reg notes These are the first 10 lines

range unr[egion] `[`face`]`
  The `:unregion` command cancels the region highlighting for the given range of lines. If you supply a face name, then it will only cancel regions which were using that face; otherwise it cancels all regions within the range. The following example gets rid of all "notes" regions, but leaves other regions unchanged:

      	:%unr notes

range chr[egion] face newface `[`newcomment`]`
  The `:chregion` command changes one type of region into another type, based on the face. The following is a nifty trick which automatically marks changed lines as "unsaved" while you're editing, and then converts those to "saved" when you write the file.

      	:color unsaved on red
      	:color saved on green
      	:autocmd Edit * '[,']region unsaved
      	:autocmd BufWritePost * %chregion unsaved saved

Also, running ":load `inregion`" will add an "`:inregion` face excmds" alias, which you can use to execute commands on lines in a given type of region.

## 4.21 Spell checking

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | wo[rds][!]        | [+ | -] words...                  |
    |       | wordf[ile][!]     | [filename...]                     |
    |       | che[ck][!]        | [* | + | -] faces...              |
    ^-------^-------------------^-----------------------------------^

These commands are only available if the spell-checking feature is enabled. (The command ``:calc feature("spell")`' should say True.) For more information about the spell checker, see the section in the Tips chapter, and the spelling options.

wo[rds]`[`!`]` `[`+`|`-`] [`words...`]`
  Adds words to the natural-language dictionary. Words that follow a "-" flag will be added as *BAD* words; otherwise the words are added as good words.

  When invoked without any arguments, it lists any words that you've added with previous invocations of the `:words` command.

  If you use a "!" suffix on the command name, then the added words will not be marked as though they were added via :words. This is used mostly in Elvis' initialization scripts. Words added this way won't be listed by an argumentless `:words` command, and won't be saved via the :mkexrc command.

          .------------.-------------------------------------------.
          | COMMAND    | WHAT IT DOES                              |
          |------------|-------------------------------------------|
          | :wo word   | Add word to personal dictionary as "good" |
          | :wo -word  | Add word to personal dictionary as "bad"  |
          | :wo! word  | Add word as "good", but not "personal"    |
          | :wo! -word | Add word as "bad" but not "personal"      |
          |            |   (This effectively removes the word from |
          |            |   the dictionary.)                        |
          ^------------^-------------------------------------------^

  Words given in lowercase will be assumed to be case-insensitive. Words containing any uppercase letters will be case-sensitive. Also, there's a minor bug involving case-sensitive words and the spellsuffix option; see the "Options" chapter for details.

wordf[ile]`[`!`]` `[`filename...`]`
  Scan a text file for words, and add them to the natural-language dictionary. The text file shouldn't contain any markups such as HTML tags; it must be a plain text file. However, the words do not need to be sorted or formatted in any special way. You can use the :wascii alias to generate a plain text file from an HTML, man, or TeX source file.

  When invoked without any arguments, `:wordfile` loads the words from the file indicated by the spelldict option. Doing this will take a noticeable amount of time, but it will allow the spell() function to work better.

  When invoked with filenames as arguments, it scans those files for words and adds them to your personal dictionary, so they'll be saved by the :mkexrc command. You can also add words temporarily by using `:wordfile!` (with a ! suffix).

che[ck]`[`!`]` `[`*`|`+`|`-`] [`faces...`]`
  This command allows you to reduce the amount of spell-checking that is performed on specific text faces. The face names are the same ones the :color command uses. By default, most faces are spell-checked; Elvis' default configuration files (mostly elvis.spe) reduce spell checking for a few carefully-chosen faces.

  If invoked without any arguments, it will list any fonts that you've changed with previous invocations of the `:check` command.

  If invoked with arguments, then the arguments should be a mixture of flags and face names. Each flag indicates which type of spell-checking is allowed on any text that is drawn in the faces that follow it. The flags are:

  * Check tags and natural-language words.
  + Check tags, but not natural-language words.
  - Don't check against either list.

  If you don't use any of those flags, then "+" is assumed.

  "tags" refers to the list of symbol names defined in a file named "tags", in any directory named in the tags option. For convenience, it also looks for "tags" in the directories listed in the elvispath option; many people set up a list of standard library functions there.

  "natural-language words" refers to the list of words maintained by the :words command, or stored in an external file named via the spelldict option.

  Some examples:

      .-----------------------.----------------------------------------.
      | COMMAND               | WHAT IT DOES                           |
      |-----------------------|----------------------------------------|
      | :che +variable        | enable tag-only checking for variables |
      | :che variable         | same as ":check +variable"             |
      | :che *string          | enable full checking for strings       |
      | :che -variable string | turn off all checking for those fonts  |
      ^-----------------------^----------------------------------------^

  For example, the default configuration disables spell-checking on variable names, since most tag-generator programs don't generate tags for all variables. If you use a tag generator that does generate tags for all variables, then you may want to enable checking against tags. You still wouldn't want to check variable names against natural-language words, though. The command to enable this checking for variables is:

      	:check variable

  Strings aren't normally spell-checked, because strings often contain quirky things like "\n" and "%d", which causes many false alarms. However, if you want to enable natural-language checking for strings, you can do it with this command:

      	:check *string

  Appending a "!" suffix to the command name will prevent the changed font from being listed by a later, argumentless `:check` command, or from being saved by a :mkexrc command. Elvis' initialization scripts invoke it this way.

## 4.22 Miscellaneous

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | "                 | text                              |
    |       | cd[!]             | [directory]                       |
    |       | chd[ir][!]        | [directory]                       |
    |       | ec[ho]            | text                              |
    |       | me[ssage]         | text                              |
    |       | wa[rning]         | text                              |
    |       | erro[r]           | text                              |
    | range | norm[al][!]       | [keystrokes]                      |
    |       | sh[ell]           |                                   |
    |       | st[op][!]         |                                   |
    |       | sus[pend][!]      |                                   |
    |       | ve[rsion]         |                                   |
    | line  | go[to]            |                                   |
    | line  | ma[rk]            | mark                              |
    | line  | k                 | mark                              |
    |       | {                 |                                   |
    ^-------^-------------------^-----------------------------------^

" text
  The `:"` command causes the remainder of the line to be ignored. It is used for inserting comments into ex scripts.
cd`[`!`]` `[`directory`]`
chd[ir]`[`!`]` `[`directory`]`
  The `:cd` and `:chdir` commands are identical. They both change the current working directory for Elvis and all its windows. If you don't specify a new directory name then Elvis will switch to your home directory.
ec[ho] text
  The `:echo` command displays its arguments as a message. This may be useful in ex scripts.
me[ssage] text
wa[rning] text
erro[r] text
  The `:message`, `:warning`, and `:error` commands all output their arguments as a message. The command name indicates the importance of the message. This is differs from `:echo` as follows: the messages are translated via the elvis.msg file, then evaluated using the simpler syntax, and finally stuffed into the message queue. The message queue collects all messages, and outputs them immediately before waiting for the next keystroke. Also, the `:error` command has the side-effect of terminating any macros, aliases, or scripts.

  When used inside an autocmd, error and warning messages are normally hidden. To enable them in an `autocmd`, you should turn on the eventerrors option.

  When used inside a try command, errors and warnings are always hidden.

range norm[al]`[`!`] [`keystrokes`]`
  The `:normal` command does two totally separate things. When invoked without any parameters, it switches to the normal display mode.

  When `:normal` is invoked with parameter text, though, it leaves the display mode unchanged and interprets the characters of the text as though they were vi commands. If no addresses were given, then those commands are executed once, without moving the cursor initially; if an address or range of addresses were given, then it moves the cursor to the first character of each line and repeats the vi command keys there.

  The "!" suffix has no effect in Elvis. In vim, it would prevent maps from being applied to the simulated keystrokes, but Elvis never applies maps to `:normal` keystrokes.

sh[ell]
  The `:shell` command starts up an interactive shell (command-line interpreter). Elvis will be suspended while the shell executes. (Exception: the "x11" GUI runs the shell in a separate xterm window. Then Elvis and the shell can then run simultaneously.)
st[op]`[`!`]`
sus[pend]`[`!`]`
  The `:stop` and `:suspend` commands are identical to each other. If the operating system and user interface support it, they will suspend Elvis and resume the shell that started Elvis. (This is like hitting `^Z` on many UNIX systems.) If the OS or GUI don't support it, then Elvis will generally treat these commands as synonyms for the `:shell` command.
ve[rsion]
  The `:version` command identifies this version number of Elvis, and displays credits.
line go[to]
  The `:goto` moves the cursor to the addressed line.

  If you give an address without any ex command, then Elvis will assume you want to use the `:goto` command.

line ma[rk] mark
line k mark
  The `:mark` and `:k` commands are identical to each other. They set a named mark to equal the addressed line, or the current line if no address was given.
{ commands }
  The `{ commands }` notation isn't really a command; it is a feature of Elvis' syntax which allows you to pass several command lines to a command which normally expects a single command line as its argument. It is supported by the :global, :vglobal, :all, :then, :else, :alias, and :autocmd commands. Instead of placing the argument command at the end of one of those command lines, you can place a single '{' character there. That should be followed by one or more command lines, and terminated by a '}' on a line by itself.

## 4.23 Alphabetical list of ex commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ab[breviate][!]   | [lhs rhs]                         |
    |       | al[ias]           | [name [excmds]]                   |
    |       | al[l][!]          | excmds                            |
    | line  | a[ppend][!]       | [text]                            |
    |       | ar[gs]            | [file...]                         |
    |       | aug[roup][!]      | [group]                           |
    |       | au[tocmd][!]      | [group] [events [file [excmd]]]   |
    |       | bb[rowse]         |                                   |
    |       | bre[ak][!]        | [flags] lhs                       |
    |       | br[owse][!]       | restrictions                      |
    |       | b[uffer][!]       | [buffer]                          |
    |       | ca[lculate]       | expr                              |
    |       | cas[e]            | value [excmds]                    |
    |       | cc[!]             | [args]                            |
    |       | cd[!]             | [directory]                       |
    | range | c[hange][!]       | [count] [text]                    |
    |       | chd[ir][!]        | [directory]                       |
    |       | che[ck][!]        | [* | + | -] faces...              |
    | range | chr[egion]        | face newface [newcomment]         |
    |       | cl[ose][!]        |                                   |
    |       | col[or]           | [face [attributes]]               |
    | range | co[py]            | line                              |
    |       | def[ault]         | excmds                            |
    | range | d[elete]          | [cutbuf] [count]                  |
    |       | dig[raph][!]      | [lhs [rhs]]                       |
    |       | di[splay]         | [modename [language]]             |
    |       | do[loop]          | excmds                            |
    |       | ec[ho]            | text                              |
    |       | e[dit][!]         | [+line] [file]                    |
    |       | el[se]            | excmds                            |
    |       | er[rlist][!]      | [file]                            |
    |       | erro[r]           | text                              |
    |       | ev[al]            | expr                              |
    |       | ex[!]             | [+line] [file]                    |
    |       | f[ile]            | [file]                            |
    | range | fo[ld][!]         | [name]                            |
    |       | for[each]         | option ["in"] expression          |
    | range | g[lobal][!]       | /regexp/ excmds                   |
    | line  | go[to]            |                                   |
    |       | gu[i]             | text                              |
    |       | h[elp]            | topic                             |
    |       | if                | expr                              |
    | line  | i[nsert][!]       | [text]                            |
    | range | j[oin][!]         |                                   |
    | line  | k                 | mark                              |
    |       | la[st]            |                                   |
    |       | le[t][!]          | option=expr                       |
    | range | l[ist]            | [count]                           |
    |       | lo[cal]           | [option=value | option ]          |
    | range | lp[r][!]          | [ file | >>file | !shellcmd ]     |
    |       | mak[e][!]         | [args]                            |
    |       | map[!]            | [flags] [lhs [flags] rhs]         |
    | line  | ma[rk]            | mark                              |
    |       | me[ssage]         | text                              |
    |       | mk[exrc][!]       | [file]                            |
    | range | m[ove]            | line                              |
    |       | new               |                                   |
    |       | n[ext][!]         | [file...]                         |
    |       | N[ext][!]         |                                   |
    |       | noh[lsearch]      |                                   |
    | range | norm[al][!]       | keystrokes                        |
    | range | nu[mber]          | [count]                           |
    |       | on[ly]            |                                   |
    |       | o[pen][!]         | [+line] [file]                    |
    |       | po[p][!]          |                                   |
    |       | pres[erve]        |                                   |
    |       | pre[vious][!]     |                                   |
    | range | p[rint]           | [count]                           |
    |       | pus[h][!]         | [+line] [file]                    |
    | line  | pu[t]             | [cutbuf]                          |
    |       | qa[ll][!]         |                                   |
    |       | q[uit][!]         |                                   |
    | line  | r[ead]            | file | !shellcmd                  |
    |       | red[o]            | [count]                           |
    | range | reg[ion]          | [face [comment]]                  |
    |       | rew[ind][!]       |                                   |
    |       | sN[ext]           |                                   |
    |       | safel[y][!        | excmds                            |
    |       | sa[ll]            |                                   |
    |       | sbb[rowse]        |                                   |
    |       | sb[rowse]         | restrictions                      |
    |       | se[t][!]          | [option=value | option? | all]    |
    |       | sh[ell]           |                                   |
    |       | sl[ast]           |                                   |
    |       | sne[w]            |                                   |
    |       | sn[ext]           | [file...]                         |
    |       | so[urce][!]       | file                              |
    |       | sp[lit]           | [+line] [file | !shellcmd]        |
    |       | sre[wind][!]      |                                   |
    |       | stac[k]           |                                   |
    |       | sta[g]            | [tag]                             |
    |       | st[op][!]         |                                   |
    | range | s[ubstitute]      | /regexp/newtext/[g][p][x][count]  |
    |       | sus[pend][!]      |                                   |
    |       | sw[itch]          | expr                              |
    |       | ta[g][!]          | [tag]                             |
    |       | th[en]            | excmds                            |
    | range | t[o]              | line                              |
    |       | try               | excmds                            |
    |       | una[bbreviate][!] | lhs                               |
    |       | unal[ias][!]      | name                              |
    |       | unb[reak][!]      | [flags] lhs                       |
    |       | u[ndo]            | [count]                           |
    | range | unf[old][!]       | [name]                            |
    |       | unm[ap][!]        | [flags] lhs                       |
    | range | unr[egion]        | [face]                            |
    |       | ve[rsion]         |                                   |
    | range | v[global][!]      | /regexp/ excmds                   |
    |       | vi[sual][!]       | [+line] [file]                    |
    |       | wa[rning]         | text                              |
    |       | wh[ile]           | expr                              |
    |       | wi[ndow]          | [+ | - | number | buffer ]        |
    |       | wn[ext][!]        |                                   |
    |       | wordf[ile][!]     | [filename...]                     |
    |       | wo[rds][!]        | [+ | -] words...                  |
    |       | wq[uit][!]        | [file]                            |
    | range | w[rite][!]        | [file | >>file | !shellcmd]       |
    |       | x[it][!]          | [file]                            |
    | range | y[ank]            | [cutbuf] [count]                  |
    | line  | z                 | [spec]                            |
    | range | !                 | shellcmd                          |
    |       | "                 | text                              |
    | range | #                 | [count]                           |
    | range | &                 |                                   |
    |       | (                 | buffer                            |
    | range | <                 |                                   |
    | range | =                 |                                   |
    | range | >                 |                                   |
    |       | @                 | cutbuf                            |
    |       | {                 |                                   |
    | range | ~                 |                                   |
    ^-------^-------------------^-----------------------------------^