4. EX COMMAND MODE

4.1 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.

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.

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.

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.

   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"

4.2 Ex Commands, Grouped by Function

  • 4.2.1 The help command itself
  • 4.2.2 Editing commands
  • 4.2.3 Global edit commands
  • 4.2.4 Displaying text
  • 4.2.5 Tags
  • 4.2.6 File I/O commands
  • 4.2.7 The args list, and selecting a file to edit
  • 4.2.8 Quitting
  • 4.2.9 Scripts and macros
  • 4.2.10 Working with a compiler
  • 4.2.11 Built-in calculator
  • 4.2.12 Buffer commands
  • 4.2.13 Window commands
  • 4.2.14 Configuration
  • 4.2.15 Miscellaneous
  • 4.2.1 The help command itself

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | 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 :XXX    | If XXX is an ex command name, elvis will  |
    	|               |   show its description; else elvis will   |
    	|               |   list groups of all ex commands.         |
    	| :help XXX     | If XXX appears to be represent 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 sections on ex commands, vi commands, and options, there are many others 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:

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

    4.2.2 Editing commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | line  | a[ppend][!]       | [text]                            |
    | line  | i[nsert][!]       | [text]                            |
    | range | c[hange][!]       | [count] [text]                    |
    | 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]                           |
    ^-------^-------------------^-----------------------------------^
    
    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.

    The :insert command inserts text before the current line. Other than that, it is identical to the :append command.

    The :change command deletes old text lines (optionally into a named 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.

    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.

    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

    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.1. 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)$

    The :move command resembles :copy except that :move deletes the original text.

    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.

    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.

    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 an exclamation point, as :join!, it joins the lines without doing fancy things to whitespace.

    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.2.3 Global edit commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | range | g[lobal][!]       | /regexp/ excmds                   |
    | range | v[global][!]      | /regexp/ excmds                   |
    | range | s[ubstitute]      | /regexp/newtext/[g][p][x][count]  |
    | range | &                 |                                   |
    | range | ~                 |                                   |
    ^-------^-------------------^-----------------------------------^
    
    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/.

    The :substitute command searches for the /regexp/ in each line, and replaces the matching text with newtext. The interpretation of newtext is described in section 5.2

    The newtext can be followed by a count or g flag to determine which matches are changed within each line. Without any count or g flag, only the first match within each line is changed. If a count is supplied, then only that match within each line will be replaced. If a g flag is given, then all matches in each line will be replaced.

    You can also supply a p flag. This causes each affected line to be printed, after all substitutions have been made to that line.

    Elvis also supports an 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:

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

    The :& and :~ commands are identical to each other. They both repeat the previous :substitute command.

    4.2.4 Displaying text

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | range | p[rint]           | [count]                           |
    | range | l[ist]            | [count]                           |
    | range | nu[mber]          | [count]                           |
    | range | #                 | [count]                           |
    | line  | z                 | [spec]                            |
    | range | =                 |                                   |
    ^-------^-------------------^-----------------------------------^
    
    The :print command displays lines from the edit buffer. It displays them the normal way -- with tabs expanded and so on.

    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.

    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.

    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.      |
       ^------^-----------------------------------------------------^ 

    The := command 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.2.5 Tags

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ta[g][!]          | [tag]                             |
    |       | stac[k]           |                                   |
    |       | po[p][!]          |                                   |
    ^-------^-------------------^-----------------------------------^
    
    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.

    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.

    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.

    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. Elvis doesn't support any network protocols, so its URLs can only consist of a file name and/or a #label. The following example would move the cursor to the start of this section:

    :tag elvisopt.html#TAGS

    4.2.6 File I/O commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    | line  | r[ead]            | file | !shellcmd                  |
    | range | w[rite][!]        | [file | >>file | !shellcmd]       |
    | range | lp[r][!]          | [file | >>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

    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.

    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.2.7 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.

    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.

    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.

    The :Next (with a capital "N") and :previous commands are identical to each other. They both move backwards through the args list.

    The :rewind and :last commands switch to the first and last files in the args list, respectively.

    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.)

    The :file command displays information about the current buffer. It can also be used to change the filename associated with this buffer.

    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.

    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.2.8 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.

    The :close command is the simplest. If the current window is the only window, 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.

    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.

    The :xit command saves the file if it has been modified, and then closes the window. The visual ZZ command uses this command internally.

    The :wquit command saves the file regardless of whether it has been modified, and then closes the window.

    The :qall command tries to close all of the windows at once. It is equivalent to giving the :quit command in each window.

    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 "~/elvis1.ses". You may want to check the value of the session option first, just to make sure.

    4.2.9 Scripts and macros

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | @                 | cutbuf                            |
    |       | so[urce][!]       | file                              |
    |       | saf[er][!]        | file                              |
    ^-------^-------------------^-----------------------------------^
    
    The :@ command executes the contents of a cut buffer as a series of ex command lines.

    The :source 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.

    The :safer command is exactly like :source, except that :safer will temporarily set the safer option while it is executing the commands. You should use :safer instead of :source when it is possible that the file to be executed could contain potentially harmful commands. For example, the default "elvis.ini" file use :source to execute the ".exrc" file in your home directory since it is presumably secure, but :safer is used to execute the ".exrc" file in the current directory since it could have been created by anybody.

    4.2.10 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.

    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.)

    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.2.11 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 and :let commands also use the calculator.

    The :calculate command evaluates an expression and displays the result.

    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)

    4.2.12 Buffer commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | al[l][!]          | excmds                            |
    |       | b[uffer][!]       | [newname]                         |
    |       | (                 | buffer                            |
    ^-------^-------------------^-----------------------------------^
    
    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=c

    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 change the name of an existing buffer. Right now I can't remember why I bothered to implement this feature.

    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.

    4.2.13 Window commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | sp[lit]           | [file]                            |
    |       | new               |                                   |
    |       | sne[w]            |                                   |
    |       | sn[ext]           | [file...]                         |
    |       | sN[ext]           |                                   |
    |       | sre[wind][!]      |                                   |
    |       | sl[ast]           |                                   |
    |       | sta[g]            | [tag]                             |
    |       | sa[ll]            |                                   |
    |       | wi[ndow]          | [+ | - | number | buffer ]        |
    |       | di[splay]         | [modename [language]]             |
    |       | no[rmal]          |                                   |
    ^-------^-------------------^-----------------------------------^
    
    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. Otherwise, the new window will show the same buffer as the current window.

    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.

    The :snext, :sNext, :srewind, :slast, and :stag commands resemble the :next, :Next, :rewind, :last, and :tag commands, respectively, except that these "s" versions create a new window for the newly loaded file, and leave the current window unchanged.

    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.2.7: The args list... for a discussion of the args list.)

    The :window either lists all windows (when invoked with no arguments) or switches to a given window. You can specify which which to switch to by giving one of the following arguments.

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

    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.

    The :normal command is equivalent to ":display normal". It can be abbreviated to ":no", which is certainly easier to type than ":dis normal".

    4.2.14 Configuration

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ab[breviate][!]   | [lhs rhs]                         |
    |       | una[bbreviate][!] | lhs                               |
    |       | map[!]            | [lhs rhs]                         |
    |       | unm[ap][!]        | lhs                               |
    |       | br[eak][!]        | lhs                               |
    |       | unb[reak][!]      | lhs                               |
    |       | dig[raph][!]      | [lhs [rhs]]                       |
    |       | col[or]           | [font color ["on" color]]         |
    |       | gu[i]             | text                              |
    |       | se[t][!]          | [option=value | option? | all]    |
    |       | le[t][!]          | option=expr                       |
    |       | if                | expr                              |
    |       | th[en]            | excmds                            |
    |       | el[se]            | excmds                            |
    |       | mk[exrc][!]       | [file]                            |
    ^-------^-------------------^-----------------------------------^
    
    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.

    The :map and :unmap commands add and remove entries to the map tables, respectively. When the :map command is given without any arguments, it lists the contents of a map table.

    There are two map tables. When a "!" is appended to the command name, these commands use the table that applies to input mode; without the "!" these commands use the table that applied to visual command mode.

    The primary purpose of map tables 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 argument to :map is the raw character sequence sent by a key, and the remaining arguments are the characters that elvis should pretend you pressed. The second argument may be preceded by the word "visual" which causes the remaining argument characters to be processed as visual commands, even if the key is pressed in input mode. This trick is used to allow the cursor to be moved via the arrow keys when in input mode.

    The :break and :unbreak commands set and reset the breakpoint flag for a given macro, respectively. This is used for debugging macros, as described in section 14.1: 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.

    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.

    The :color command allows you to choose a color to use for displaying each font. Some user interfaces don't support this. The ones that do will vary in the color names that they support. The termcap interface supports black, white, gray, red, green, blue, brown, yellow, magenta, and cyan, plus bright versions of most of those. The x11 interface supports all standard X color names.

    The first argument should be the name of the font to change. This can be "normal", "bold", "emphasized", "italics", "underlined", "standout", or "fixed". Some user interfaces may also support "cursor" and/or "scrollbar". All of these can be either spelled out completely, or abbreviated to the first letter. (Currently no user interface supports both "standout" and "scrollbar" so there is no ambiguity.) If you omit the font name, then "normal" is assumed. The termcap interface requires you to assign a "normal" color before any of the other fonts.

    You can specify an optional background color. The word "on" is used to delimit the foreground color name from the background color name. For example, the command ":color yellow on blue" causes normal text to be displayed as yellow characters on a blue background.

    The :gui command provides a way to pass unusual commands to the user interface. Currently no user interface supports this command, so you can ignore it for now.

    The :set command allows you to examine or change the values of options. Adding a "!" to the end of the command name causes it to include the group name of any option that is output.

    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 value of (nearly) all options. Giving the name of an option, or group of options, followed by a "?" character, will cause :set to output the option or all options in the 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.

    The :let command computes a new value for an option. The :let command should be followed by the name of an option, then an "=" sign, and then an expression that produces the new value. Note that even Boolean options use the "=" notation here.

    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. Another thing to watch out for is the fact that there is only one "if" variable and therefore you can't nest :if commands as you might expect.

    The :mkexrc command creates a file containing ex commands which recreate the current map, abbreviation, and digraph tables, and also sets any options which have been changed. Basically it stores your current configuration in a file which you can later :source to restore your configuration. If you don't specify a filename, then it will write to ".exrc" or "elvis.rc" in the current directory.

    4.2.15 Miscellaneous

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | "                 | text                              |
    |       | cd[!]             | [directory]                       |
    |       | chd[ir][!]        | [directory]                       |
    |       | ec[ho]            | text                              |
    |       | sh[ell]           |                                   |
    |       | st[op][!]         |                                   |
    |       | sus[pend][!]      |                                   |
    |       | ve[rsion]         |                                   |
    | line  | go[to]            |                                   |
    | line  | ma[rk]            | mark                              |
    | line  | k                 | mark                              |
    ^-------^-------------------^-----------------------------------^
    
    The " command causes the remainder of the line to be ignored. It is used for inserting comments into ex scripts.

    The :cd and :chdir commands are identical. They both change the current working directory for elvis and all its windows. The you don't specify a new directory name then elvis will switch to your home directory.

    The :echo command displays its arguments as a message. This may be useful in ex scripts.

    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. The elvis and the shell can then run simultaneously.)

    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.

    The :version command identifies this version number of elvis, and displays credits.

    The :goto moves the cursor to the addressed line. This is the only command which can be abbreviated down to zero characters, so if you type in a line containing just a line address, then elvis will treat that as a :goto command.

    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.

    4.3 Alphabetical list of ex commands

    .-------.-------------------.-----------------------------------.
    |ADDRESS| COMMAND           | ARGUMENTS                         |
    |-------|-------------------|-----------------------------------|
    |       | ab[breviate][!]   | [lhs rhs]                         |
    |       | al[l][!]          | excmds                            |
    | line  | a[ppend][!]       | [text]                            |
    |       | ar[gs]            | [file...]                         |
    |       | br[eak][!]        | lhs                               |
    |       | b[uffer][!]       | [buffer]                          |
    |       | ca[lculate]       | expr                              |
    |       | cc[!]             | [args]                            |
    |       | cd[!]             | [directory]                       |
    | range | c[hange][!]       | [count] [text]                    |
    |       | chd[ir][!]        | [directory]                       |
    |       | cl[ose][!]        |                                   |
    |       | col[or]           | [font color ["on" color]]         |
    | range | co[py]            | line                              |
    | range | d[elete]          | [cutbuf] [count]                  |
    |       | dig[raph][!]      | [lhs [rhs]]                       |
    |       | di[splay]         | [modename [language]]             |
    |       | ec[ho]            | text                              |
    |       | e[dit][!]         | [+line] [file]                    |
    |       | el[se]            | excmds                            |
    |       | er[rlist][!]      | [file]                            |
    |       | ev[al]            | expr                              |
    |       | ex[!]             | [+line] [file]                    |
    |       | f[ile]            | [file]                            |
    | 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]                           |
    | range | lp[r][!]          | [ file | >>file | !shellcmd ]     |
    |       | mak[e][!]         | [args]                            |
    |       | map[!]            | [lhs rhs]                         |
    | line  | ma[rk]            | mark                              |
    |       | mk[exrc][!]       | [file]                            |
    | range | m[ove]            | line                              |
    |       | new               |                                   |
    |       | n[ext][!]         | [file...]                         |
    |       | N[ext][!]         |                                   |
    |       | no[rmal]          |                                   |
    | range | nu[mber]          | [count]                           |
    |       | o[pen][!]         | [+line] [file]                    |
    |       | po[p][!]          |                                   |
    |       | pre[vious][!]     |                                   |
    | range | p[rint]           | [count]                           |
    | line  | pu[t]             | [cutbuf]                          |
    |       | qa[ll][!]         |                                   |
    |       | q[uit][!]         |                                   |
    | line  | r[ead]            | file | !shellcmd                  |
    |       | red[o][!]         | [count]                           |
    |       | rew[ind][!]       |                                   |
    |       | sN[ext]           |                                   |
    |       | saf[er][!]        | file                              |
    |       | sa[ll]            |                                   |
    |       | se[t][!]          | [option=value | option? | all]    |
    |       | sh[ell]           |                                   |
    |       | sl[ast]           |                                   |
    |       | sne[w]            |                                   |
    |       | sn[ext]           | [file...]                         |
    |       | so[urce][!]       | file                              |
    |       | sp[lit]           | [file]                            |
    |       | sre[wind][!]      |                                   |
    |       | stac[k]           |                                   |
    |       | sta[g]            | [tag]                             |
    |       | st[op][!]         |                                   |
    | range | s[ubstitute]      | /regexp/newtext/[g][p][x][count]  |
    |       | sus[pend][!]      |                                   |
    |       | ta[g][!]          | [tag]                             |
    |       | th[en]            | excmds                            |
    | range | t[o]              | line                              |
    |       | una[bbreviate][!] | lhs                               |
    |       | unb[reak][!]      | lhs                               |
    |       | u[ndo]            | [count]                           |
    |       | unm[ap][!]        | lhs                               |
    |       | ve[rsion]         |                                   |
    | range | v[global][!]      | /regexp/ excmds                   |
    |       | vi[sual][!]       | [+line] [file]                    |
    |       | wi[ndow]          | [+ | - | number | buffer ]        |
    |       | wn[ext][!]        |                                   |
    |       | 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 | &                 |                                   |
    | range | <                 |                                   |
    | range | =                 |                                   |
    | range | >                 |                                   |
    |       | @                 | cutbuf                            |
    | range | ~                 |                                   |
    ^-------^-------------------^-----------------------------------^