COHERENT manpages

This page displays the COHERENT manpage for elvis [Clone of Berkeley-standard screen editor].

List of available manpages
Index


elvis -- Command

Clone of Berkeley-standard screen editor
elvis [ options ] [ +cmd ] [ file1 ... file27 ]

elvis is a clone of vi and ex, the standard UNIX screen editors.

elvis  is a  modal editor  whose  command structure  resembles the  ed line
editor.   Modal  means  that  a  keystroke  assumes  a  different  meaning,
depending upon  the mode that  the editor is  in.  elvis uses  three modes:
visual-command mode, colon-command mode, and input mode.

The following sections summarize the commands associated with each mode:

Visual-Command Mode

Visual-command mode  closely resembles text-input  mode.  One quick  way to
tell the modes apart is to press the <esc> key.  If elvis beeps, then
you are  in visual-command  mode.  If  it does not  beep, then you  were in
input mode, but pressing <esc> switched you to visual-command mode.

Most visual-mode commands are one  keystroke long.  The commands are in two
groups: movement  commands and edit  commands.  The former  group moves the
cursor through the file being edited, and the latter group alters text.

The following sections summarize the command set for elvis's visual-command
mode.

Visual-Mode Movement Commands

The  following  summarizes  the  visual  mode's movement  commands.   count
indicates that  the command can be optionally prefaced  by an argument that
tells  elvis how  often to  execute the command.   move indicates  that the
command can be  followed by a movement command, after  which the command is
executed on  the text  that lies  between the point  where the  command was
first  typed and  the point  to  which the  cursor was  moved.  Typing  the
command a second  time executes the command for the  entire line upon which
the cursor is  positioned.  key means that the command  must be followed by
an argument.

<ctrl-B>
             Move up by one screenful.
[count] <ctrl-D>
             Scroll down count lines (default, one-half screenful).
[count] <ctrl-E>
             Scroll up count lines.
<ctrl-F>
             Move down by one screenful.
<ctrl-G>
             Show file status and the current line.
[count] <ctrl-H>
             Move one character to the left.
[count] <ctrl-J>
             Move down count lines.
<ctrl-L>
             Redraw the screen.
[count] <ctrl-M>
             Move to the beginning of the next line.
[count] <ctrl-N>
             Move down count lines (default, one).
[count] <ctrl-P>
             Move up count lines (default, one).
<ctrl-R>
             Redraw the screen.
<ctrl-T>
             Pop the  tag stack  -- that  is, return  to the  most recently
             tagged position.  elvis removes that tag from the tag stack.
[count] <ctrl-U>
             Scroll up count lines (default, one-half screenful).
[count] <ctrl-X>
             Move the cursor to column count on the current line.
[count] <ctrl-Y>
             Scroll down count lines.
<ctrl-]>
             If the cursor is on a tag name, go to that tag.
<ctrl-^>
             Switch to the previous file.
[count] <space>
             Move right count spaces (default, one).
<quotation mark> key
             Select which cut buffer to use next.
$            Move to the end of the current line.
%            Move to the matching (){}[] character.
[count] %    Move count percentage into the file.  For example, the command
             50% moves the cursor to the middle of the file.
' key        Move to a marked line.
[count] (    Move backward count sentences (default, one).
[count] )    Move forward count sentences (default, one).
*            Go to the next error in the error list.
[count] +    Move to the beginning of the next line.
[count] ,    Repeat the previous f  or t command, but  move in the opposite
             direction.
[count] -    Move to the beginning of the preceding line.
[count] .    Repeat the previous edit command.
/ text       Search forward for text, which can be a regular expression.
0            If not part  of a count,  move to the first  character of this
             line.
:            Switch to colon-command mode to execute one command.
[count] ;    Repeat the previous f or t command.
? text       Search backwards for text, which can be a regular expression.
@ key        Execute the contents of a cut-buffer as vi commands.
[count] B    Move backwards count words (default, one).
[count] E    Move forwards count words (default, one).
[count] F key
             Move left to  the count'th  occurrence of the  given character
             (default, first).
[count] G    Move to to line count (default, last).
[count] H    Move to the top of the screen.
[count] L    Move to the bottom of the screen.
M            Move to the middle of the screen.
N            Repeat the last search, but in the opposite direction.
P            Paste text before the cursor.
Q            Shift to colon-command mode.
[count] T key
             Move left almost to the given character.
U            Undo all recent changes to the current line.
V [move...][command]
             Like v,  described below,  except it  applies to  whole lines.
             For example,  the command  Vjj> first  highlights  and then
             indents three lines.  It is equivalent to >2j or 3>>.
[count] W    Move forward count words (default, one).
[count] Y    Copy (or ``yank'')   count lines  into a cut  buffer (default,
             one).
Z Z          Save the file and exit.
[ [          Move back one section.
] ]          Move forward one section.
^            Move to the beginning of the current line, but after indent.
` key        Move to the key character.
[count] b    Move back count words.
[count] e    Move forward to the end of the count'th word.
[count] f c  Move rightward to the count'th occurrence of character c.
[count] h    Move left count characters (default, one).
[count] j    Move down count characters (default, one).
[count] k    Move up count characters (default, one).
[count] l    Move right count characters (default, one).
m key        Mark a line or character.
n            Repeat the previous search.
p            Paste text after the cursor.
[count] t key
             Move rightward almost to the count'th  occurrence of the given
             character (default, one).
u            Undo the previous edit command.
v [move ...][command]
             Highlight text as the  cursor is moved, then  apply command to
             the highlighted text.  For example, vwwwd is approximately the
             same as  3dw.  To cancel  the selection  without altering  the
             text, press v a second time.
[count] w    Move forward count words (default, one).
y move       Copy (or ``yank'') text into a cut buffer.
z key        Scroll the screen, repositioning the  current line as follows:
             + indicates  top of  the screen,  --  indicates the  bottom, .
             indicates the middle.
[count] {    Move back count paragraphs (default, one).
[count] |    Move to the count'th column on the screen (leftmost, one).
[count] }    Move forward count paragraphs (default, one).

If you are running elvis within  an X terminal window, you can use also the
mouse to  reposition the cursor.  To bypass this  feature (e.g., to perform
the standard  X cut-and-paste tasks), press  <shift> while clicking a
mouse button.

Visual-Mode Edit Commands

The following describes the visual mode's editing commands.

! [move]     Run the selected text through an external filter program.
!!           Replace the  current  line  with  the  output of  an  external
             command.
[count] #    Increment a number by count (default, one).
[count] &amp;
             Repeat the previous :s// command count times (default, once).
< move    Shift the enclosed text left.
=[move]      Filter the affected  text.  The  default filter is  fmt, which
             performs simple paragraph formatting and word wrap.  To change
             the filter used by =, use the command :set ep=filter_name.
> move    Shift the enclosed text right.
[count] A input
             Append input to end of the line.
C input      Change text from the cursor through the end of the line.
D            Delete text from the cursor through the end of the line.
[count] I input
             Insert text at the beginning of the line (after indentations).
[count] J    Join lines the current with the following line.
K            Look up the word under the cursor.  The default lookup program
             is ref.  You can  change K  so as to  get C  language run-time
             library help for  the word under  the cursor by  executing the
             command:

                 set kp="help -f/usr/lib/helpfile -i/usr/lib/helpindex -d@"

             You can  write this  line into  file $HOME/.exrc,  which elvis
             reads before it begins execution.
[count] O input
             Open a new line above the current line.
R input      Overtype.
[count] S input
             Change lines, like cc.
[count] X    Delete count characters from the left  of the cursor (default,
             one).
[count] a input
             Insert text after the cursor.
c move       Change text.
d move       Delete text.
[count] i input
             Insert text at the cursor.
[count] o input
             Open a new line below the current line.
[count] r key
             Replace count characters with text you type (default, one).
[count] s input
             Replace count characters with text you type (default, one).
[count] x    Delete the character at which the cursor is positioned.
\            Pop up a menu of the most common operations.
[count] ~    Toggle a character between upper case and lower case.

Colon-Mode Commands

The following summarizes the set of colon-mode commands.  It is no accident
that these  commands closely  resemble those for  the ed line  editor: they
come, in  fact, from  ex, the  editor upon which  both vi (the  UNIX visual
editor) and  ed derive.  For  that reason, colon-command  mode is sometimes
called ex mode.

line indicates  whether the command can  be executed on one  or more lines.
line  can be  a regular  expression.   Some commands  can be  used with  an
optional exclamation  point; if done  so, the editor assumes  you know what
you are  doing and  suppresses the warnings  and prompts it  would normally
issue for these commands.

Most commands can be invoked simply  by typing the first one or two letters
of their names.
abbr [word full_form]
             Define word as an abbreviation for full_form.
and          This command is used with the colon-mode command if to execute
             other commands conditionally.   It is  never used on  its own.
             For more information,  see the section  Conditional Commands ,
             below.
[line] append
             Insert text after the current line.
args [file1 ... fileN]
             With no  arguments, print  the files  list on  elvis's command
             line.  With  one or  more arguments,  change  the name  of the
             current file.
cc [files]   Invoke the  C  compiler to  compile files,  and redirects  all
             error messages  into file errlist.  After the  compiler exits,
             scan the  contents of  errlist for error  messages; if  one is
             found, jump to the line and  file indicated on the error line,
             and display the error message on the status line.
cd [directory]
             Switch  the current  working  directory.   With  no  argument,
             switch to the $HOME directory.
[line][,line] change [``x]
             Replace the range of lines with the contents of cut-buffer x.
chdir [directory]
             Same as the cd command.
color [when] [[type] color] [on color]
             Set the screen's colors.  This command  works only if you have
             an ANSI-compatible color  terminal.  when defines  the type of
             text whose color is being manipulated: normal, standout, bold,
             underlined, italic,  popup, and quit.  The default  is normal.
             You may  use  the first  letter  of each  as an  abbreviation.
             color can be one of the following:

                  black     blue      green     cyan
                  red       magenta   brown     white
                  yellow    gray      grey

             Valid color types can be one  of the following: light, bright,
             or blinking.

             The first use  of color must  specify both the  foreground and
             background colors; the background color thereafter defaults to
             the  background  color  of  normal  text.   For  example,  the
             commands

                 color light cyan on blue
                 color b bright white

             set the normal text to light cyan in the foreground and a blue
             background; and then set the foreground color for bold text to
             bright white.

             Not every valid color command works  as expected on the system
             console, due  to  limitations in  the current  release of  the
             ansipc device driver.
[line][,line] copy targetline
             Copy the range of lines to after the targetline.
[line][,line] delete [``x]
             Move the range of lines into cut buffer x.
digraph[!] [XX [Y]]
             Set XX  as a  digraph for  Y. With  no arguments,  display all
             currently defined digraphs.   With one argument,  undefine the
             argument as a digraph.
edit[!] [file]
             Edit a file not named on the elvis command line.
else         This command is used with the colon-mode command if to execute
             other commands conditionally.   For more information,  see the
             section Conditional Commands , below.
errlist[!] [errlist]
             Find the  next  error message  in file  errlist, as  generated
             through elvis's cc or make commands.
file [file]  With an argument, change  the output file to  file. Without an
             argument, print information about the current output file.
[line][,line] global /regexp/ command
             Search the  range  of lines  for  all lines  that contain  the
             regular expression regexp, and execute command upon each.
if           This command is used to  execute other commands conditionally.
             For more information,  see the section  Conditional Commands ,
             below.
[line] insert
             Insert text before the current line.
[line][,line] join
             Concatenate the range of lines into one line.
[line][,line] list
             Display the  requested  range of  lines,  making all  embedded
             control characters explicit.
make [target]
             Same as the cc command, except that make is executed.
map[!] key mapped_to
             Remap key  to mapped_to. Normally,  remapping applies  just to
             visual-command mode; `!'  tells elvis  to remap the  key under
             all modes.  With no arguments, show all current key mappings.
[line] mark x
             Set a mark on line, and name it x.
mkexrc       Save current  configuration into file  ./.exrc, which  will be
             read next time you invoke elvis.
[line][,line] move targetline
             Move the range of lines to after targetline.
next[!] [files]
             Switch to the next file on the elvis command line.
Next[!]      Switch to the preceeding file on the elvis command line.
[line][,line] number
             Display the range of lines, with line numbers.
or           This command is used with the colon-mode command if to execute
             other commands conditionally.   For more information,  see the
             section Conditional Commands , below.
pop          Pop the  tag stack  -- that  is, return  to the  most recently
             tagged position.  elvis removes that tag from the tag stack.
previous[!]  Switch to the preceeding file on the elvis command line.
[line][,line] print
             Display the specified range of lines.
[line] put [``x]
             Copy text from cut buffer x after the current line.
quit[!]      Quit elvis, and return to the shell.
[line] read file
             Read the contents of file and insert them after line (default,
             the last line).
rewind[!]    Switch to the first file on the elvis command line.
[line[,line]]s/oldstring/newstring/[g]
             Substitute the first  instance of newstring  for oldstring. If
             no range of lines is indicated,  the substitution is performed
             only on the current line.  To change every instance of oldline
             into newline on  a line, append  the suffix g  (``global'') to
             this command.

             The  command  s   with  no  arguments   repeats  the  previous
             substitution.   It  is  a  synonym   for  the  command  &amp;,
             described below.
set [options]
             Set an  elvis option.   For details,  see  the section  on set
             Options, below
shell        Invoke a shell.
source file  Read a set of colon-mode commands from file, and execute them.
[line][,line] substitute /regexp/replacement/[p][g][c]
             For the range of  lines, replace the first  instance of regexp
             with replacement. p  tells elvis to  print the last  line upon
             which a substitution was performed.  g  means perform a global
             substitution, i.e.,  replace all instances  of regexp  on each
             line with replacement.  c tells elvis to  ask for confirmation
             before performing each substitution.
tag[!] tagname
             Find tagname in file tags, which records information about all
             tags.  If found, jump to the  file and line upon which the tag
             is set.
then         This command is used with the colon-mode command if to execute
             other commands conditionally.   For more information,  see the
             section Conditional Commands , below.
[line][,line] to targetline
             Copy the range of lines to after the targetline.
unabbr word  Unabbreviate word.
undo         Undo the last editing command.
unmap[!] key
             Unmap key.
version      Display the current version of elvis.
[line][,line] vglobal /regexp/ command
             Search the range  of lines for  all lines that  do not contain
             the regular expression regexp, and execute command upon each.
visual       Enter visual-command mode.
wq           Save the changed file, and exit.
[line][,line] write[!] [[&gt;&gt;]file]
             Write the  file  being  edited into  file.  With the  &gt;&gt;
             argument, append the edited text onto the end of file.
xit[!]       Same as the wq  command, described above, except  that it does
             not write files that have not changed.
[line][,line] yank [``x]
             Copy the range of lines into cut buffer x.
[line][,line] ! command
             Execute command under a subshell, then return.
[line][,line] <
             Shift the range of lines left by one tabwidth.
[line][,line] =
             With no  range of  lines specified,  print  the number  of the
             current line.  With line arguments, print the endpoints of the
             lines in question,  and the number  of lines that  lie between
             them.  (Remember, line can be a  regular expression as well as
             a number.)
[line][,line] >
             Shift the range of lines right by one tabwidth.
[line][,line] &amp;
             Repeat the last substitution command.
@ x          Read the  contents  of cut-buffer  x  as a  set of  colon-mode
             commands, and  execute  them.   With  no  arguments, list  all
             current settings.
\@           Beginning with release 1.8, elvis replaces the escape sequence
             \@ by  the word  that the  cursor  is on.   This works  in two
             special  contexts:  in regular  expressions,  and  in  any  ex
             command that  also replaces  `%' with  the current  file name.
             This escape  sequence can  simplify writing  certain  kinds of
             macros.

Conditional Commands

Beginning with  release 1.8pl3, elvis supports  conditional commands.  Some
of  these commands  set a conditional-execution  flag; others  examine that
flag and  perform (or  do not  perform) commands if  the flag is  set.  You
cannot nest conditional commands.

The colon-mode commands if, and, and or test for a condition.  Their syntax
is typical:  each must be  followed by an  expression, and and  and or must
follow an  initial if command.  Each command tests  for a single condition.
That condition  may involve  examining the options  set by the  command set
(which are described in detail in the next section), set by termcap values,
or by constants.

Colon-mode  commands then  and else  execute commands  conditionally, based
upon  the value  of the  conditional-execution flag set  by a  preceding if
command.

These  commands  most often  are  embedded in  an  initialization file,  to
initialize  elvis properly  under a variety  of conditions.   The following
gives an  example if command that  can be embedded in  a user's .exrc file.
The command  correctly sets up the  colors for both the  system console and
for an  X terminal window.  It  works around the fact  that the console can
handle color, but an X terminal window cannot:

    if term="console"
    then color yellow on blue | color quit white on blue
    else color black on white

To disable these commands, add -DNO_IF to CFLAGS, then recompile elvis.

set Options

As noted above, the command  set can set elvis's internal options.  Options
come  in three  flavors: boolean,  which turn  on or off  a feature  of the
editor; string which define the string associated with a particular action;
(e.g.,  the  name of  a  command  or feature);  and  numeric,  which set  a
dimension  for the  editor (e.g.,  the  number of  rows or  columns on  the
terminal screen).  To turn off a  boolean option, prefix it with the string
``no''.

The  following lists  the  options that  set recognizes.   Assume that  the
boolean options are on, unless the entry says otherwise:

autoindent (boolean)
               Auto-indent during input?  Default is no.
autoprint (boolean)
               When in ex mode, print the current line.
autotab (boolean)
               Can auto-indent use tabs?
autowrite (boolean)
               Is auto-write on when switching files?  Default is no.
beautify (boolean)
               Should  the editor  strip  control characters  from a  file?
               Default is no.
charattr (boolean)
               Interpret \fX sequences?  Default is no.
cc (string)    Name of the C compiler.  Default is cc -c.
columns (numeric)
               Width of the screen.  Default is 80.
digraph (boolean)
               Recognize digraphs?  Default is no.
directory (string)
               Where are temporary files kept?  Default is /usr/tmp.
edcompatible (boolean)
               Remember ``:s//'' options?  Default is no.
equalprg (boolean)
               Program to run for the `=' operator.  Default is fmt.
errorbells (boolean)
               Beep when an error occurs.
exrc (boolean) Read the ./.exrc file?  Default is no.
exrefresh (boolean)
               Write lines individually when in ex mode.
flash (boolean)
               Use visible alternative to bell.
flipcase (string)
               Non-ASCII chars flipped by the tilde character `~'.  Default
               is the NULL string.
hideformat (boolean)
               Hide text formatter commands.
ignorecase (boolean)
               Make searches case sensitive.  While in ignorecase mode, the
               searching mechanism  does not distinguish  between an upper-
               case letter and  its lower-case form.  In noignorecase mode,
               upper case  and lower case  are treated as  being different.
               Default is no.
inputmode (boolean)
               Start vi in insert mode?  Default is no.
keytime (numeric)
               Timeout for mapped key entry.  Default is two.
keywordprg (string)
               Path name of program invoked by shift-K.  Default is ref.
lines (numeric)
               Number of lines on the screen.  Default is 25.
list (boolean) Display lines in list mode?  Default is no.
magic (boolean)
               Enable the use of regular expressions in a search.  While in
               magic mode,  all meta-characters behave  as described above.
               In nomagic mode, only ^ and $ retain their special meaning.
make (string)  Name of the ``make'' program.  Default is make.
mesg (boolean) Allow messages from other users?
modelines (boolean)
               Are mode lines processed?  Default is no.
more (boolean) Pause between messages?
nearscroll (numeric)
               This  governs  when  to scroll  versus  when  to redraw  the
               screen.   If you  move the  cursor more  than the  number of
               lines  set  by   this  option,  elvis  redraws  the  screen;
               otherwise, it scrolls the screen.  The default is 15 lines.
novice (boolean)
               Set options for ease of use?  Default is no.
number (boolean)
               Turn on line numbering.
paragraphs (string)
               Names   of  nroff   ``paragraph''   commands.   Default   is
               PPppIPLPQP.
prompt (boolean)
               Show `:' prompt in ex mode.
readonly (boolean)
               Prevent overwriting of original file.  Default is no.
remap (boolean)
               Allow key maps to call other key maps.
report (numeric)
               Report  when a  given number of  changes occur.   Default is
               five.
ruler (boolean)
               Display line and column numbers.  Default is no.
safer          Toggle   elvis'  security  option.    This  option   is  set
               temporarily  during  the   execution  of  any  command  from
               modeline or ./.exrc. It disables the following commands:

                    :!        :Next     :abbreviate         :args:cc
                    :cd       :chdir    :ex       :file     :make
                    :map      :mkexrc   :next     :pop      :previous
                    :rewind   :shell    :stop     :suspend  :tag
                    :unab     :unmap    :visual   :write

               Note that  set safer does  not disable :wq,  as this command
               does not  let the  user name the  file into which  to write.
               :read is  still allowed, but  it will not let  the user read
               from a filter.

               set  safer  forbids the  user  from  altering the  following
               options:

                    autowrite    cc          directory      equalprg
                    keywordprg   make        shell          trapunsafe

               It  also  disables wildcard  expansion  and  the visual  `!'
               command.
scroll (numeric)
               Set  the  number  of  lines  the  screen  scrolls  with  the
               <ctrl-D> and <ctrl-U> commands.  Default is 12.
sections (string)
               Names of nroff ``section'' commands.  Default is NHSHSSSEse.
shell (string) Path name of the shell.  Default is /bin/sh.
showmatch (boolean)
               Show  all   matching  parentheses,  brackets,   and  braces.
               Default is no.
showmode (boolean)
               Say when editor is in input mode.  Default is no.
shiftwidth (numeric)
               Set number  of characters the  < and >  commands shift
               the screen.  Default is eight.
sidescroll (numeric)
               Set number of columns the editor scrolls.  Default is eight.
sync (boolean) Call sync() often?  Default is no.
tabstop (numeric)
               Number of columns set by a tab character.  Default is eight.
taglength (numeric)
               Number of significant  characters in a tag name.  Default is
               zero.
tags (string)  Name the list of ``tags'' files that elvis can read.
tagstack (boolean)
               Enable the tagstack.  Default is no.
term (string)  Name of  the current  terminal's termcap entry.   Default is
               $TERM.
terse (boolean)
               Give shorter error messages?  Default is no.
timeout (boolean)
               Distinguish <esc> from an arrow key?
warn (boolean) Warn if a file has been modified?
window (numeric)
               Number of lines to redraw after long move.  Default is 24.
wrapmargin (numeric)
               Left margin  to use when wrapping long  lines in input mode.
               Default is zero.
wrapscan (boolean)
               Searches wrap from end to beginning of the file.
writeany (boolean)
               Let the write command :w clobber a file.  Default is no.

Input-Mode Commands

Most keystrokes  are interpreted as  being text and  inserted directly into
the  text; however,  some  keystrokes are  still  interpreted as  commands.
Thus, you  can perform an entire session of  simple editing directly within
input mode without switching to either of the command modes.

The following summarizes the  commands that can be executed directly within
input mode:

<ctrl-A>
             Insert a copy of the last input text.
<ctrl-C>
             Send the signal SIGINT to interrupt a command.
<ctrl-D>
             Delete one indent character.
<ctrl-H>
             Erase the character before the cursor.
<ctrl-L>
             Redraw the screen.
<ctrl-M>
             Insert a newline.
<ctrl-P>
             Insert the contents of the cut buffer.
<ctrl-R>
             Redraw the screen, like <ctrl-L>.
<ctrl-T>
             Insert an indent character.
<ctrl-U>
             Move to  the beginning  of the  line.  When  you are  typing a
             command line or  search pattern on the  bottom line, <ctrl-
             U> backspaces over all characters typed so far.
<ctrl-V>
             Insert the following keystroke, even if special.
<ctrl-W>
             Backspace to the beginning of the current word.
<ctrl-Z><ctrl-Z>
             Write the file and exit elvis.
<ctrl-Z>
             Save the file  if it has  been modified, but do  not exit from
             elvis. This works only if you have set the mode autowrite.
<esc>  Shift from input mode to visual-command mode.
<del>  Delete the current character.

When elvis  is in input mode,  you can use the  keystroke <ctrl-O> to
invoke some visual commands  without exiting from input mode.  For example,
when you  are in input mode,  typing <ctrl-O>J moves down  a line but
leaves you in input mode.

Keyboard Macros

elvis Beginning  with release  1.8, elvis can  record keystokes into  a cut
buffer.  This is equivalent to a MicroEMACS ``keyboard macro''.

The following commands manipulate keyboard macros:

[a   Open a  keyboard macro.  elvis  executes all subsequent  keystrokes as
     normal, but also records them within a temporary buffer.

]a   Stop  recording  keystrokes,  and copy  the  keystrokes  into the  cut
     buffer.

@a   To replay the recorded keystrokes.

Command-line Options

elvis lets you  name up to 27 files on  the command line, thus allowing you
to edit  up to 27  files simultaneously.  The ``next  file'' and ``previous
file'' commands described above allow you to shift from one file to another
during the same editing session; in this way, for example, you can cut text
from one file and paste it into another.

elvis recognizes the following command-line options:

-r   Recover a previous edit.
-R   Invoke elvis  in ``read-only'' mode.   This is equivalent  to invoking
     elvis via the link view.
-s   Invoke elvis in ``safer'' mode.  This is equivalent to the command set
     safer, described above.
-t tag
     Begin editing at tag.
-m [ file ]
     Invoke  elvis in  error-handling mode.  It  searches through  file for
     something  that looks  like  an error  message from  a compiler,  then
     positions the cursor at that point for editing.
-e   Begin in colon-command mode.
-v   Begin in visual-command mode.
-i   Begin in input mode.
-w winsize
     Set the value of option window, which sets the size of the screen with
     which elvis works, to winsize. window is described below.
+command
     Execute command immediately upon beginning editing.  For example

         elvis +237 foo
     causes elvis  to move directly to line  237 immediately upon beginning
     to edit file foo.

Regular Expressions

elvis uses regular  expressions for searching and substitutions.  A regular
expression is a text string in which some characters have special meanings.
This is much more powerful than simple text matching.

elvis's regexp  package treats the following  one- or two-character strings
(called meta-characters) in special ways:
\( \)
     Delimit subexpressions.   When the regular expression  matches a chunk
     of  text, elvis  remembers  which portion  of that  chunk matched  the
     subexpression.  The command

         :s/regexp/newtext/

     command makes use of this feature.
^    Match  the beginning  of a  line.   For example,  to find  foo at  the
     beginning of a line, use the regular expression /^foo/. Note that ^ is
     a  metacharacter only  if  it occurs  at  the beginning  of a  regular
     expression; anywhere else, it is treated as a normal character.
$    Match the end of a line.  It is a metacharacter only when it occurs at
     the end of a regular expression;  elsewhere, it is treated as a normal
     character.   For example,  the expression /$$/  searches for  a dollar
     sign at the end of a line.
\<
     Match a  zero-length string at the  beginning of a word.   A word is a
     string  of  one or  more  letters  and digits;  it  can  begin at  the
     beginning of a line or after one or more non-alphanumeric characters.
\>
     Matches a zero-length string at the  end of a word.  A word can end at
     the end of the line or before one or more non-alphanumeric characters.
     For example,  /\<endgt;/ finds  any instance  of the word  end, but
     ignores  any  instances  of  ``end''  inside  another  word,  such  as
     ``calendar''.
.    Match any single character.
[character-list]
     Match  any  single  character  from  the  character-list.  Inside  the
     character-list, you  can denote  a span  of characters by  writing the
     first  and  last  characters, with  a  hyphen  between  them.  If  the
     character-list is  preceded by a  ^, then the  list is inverted  -- it
     matches all  characters not mentioned in the  list.  For example, /[a-
     zA-Z]/ matches  any letter, and  /[^ ]/ matches anything  other than a
     blank.
\{n\}
     Repeat the  preceding expression n  times.  This operator  can only be
     placed after something  that matches a single character.  For example,
     /^-\{80\}$/  matches  a  line  of  eighty  hyphens,  and  /\<[a-zA-
     Z]\{4\}\>/ matches any four-letter word.
\{n,m\}
     Repeat  the  preceding single-character  expression  between  n and  m
     times, inclusive.  If the m is omitted (but the comma is present) then
     it is taken to  be infinity.  For example, /"[^"]\{3,5\}"/ matches any
     pair  of  quotation  marks that  enclose  three,  four,  or five  non-
     quotation characters.
*    Repeat the  preceding single-character expression zero  or more times.
     For example, /.*/ matches a whole line.
/+   Repeat the  preceding single-character  expression one or  more times.
     It is  equivalent to \{1,\}. For example, /.\+/  matches a whole line,
     but only  if the line  contains at least  one character.  It  does not
     match empty lines.
/?   The preceding single-character expression is optional -- that is, that
     it can  occur zero  or one  times.  It is  equivalent to  \{0,1\}. For
     example, /no[- ]?one/ matches no one, no-one, and noone.

Anything else  is treated as a  normal character that must  exactly match a
character from  the scanned text.  The special strings  may all be preceded
by a backslash to force them to be treated normally.

Substitutions

The  command :s  has at  least two  arguments: a  regular expression  and a
substitution  string.  The  text  that matches  the  regular expression  is
replaced by text that is derived from the substitution string.

Most  characters  in  the substitution  string  are  copied  into the  text
literally but a few have special meaning:

&amp;
     Insert a copy of the original text.
~    Insert a copy of the previous replacement text.
\1   Insert a  copy of that portion  of the original text  that matched the
     first set of parentheses.
\2-\9
     Do the same for the second and all subsequent pairs of parentheses.
\U   Convert all characters of any later &amp; or \# to upper case.
\L   Convert all characters of any later &amp; or \# to lower case.
\E   End the effect of \U or \L.
\u   Convert the first character of the next &amp; or # to upper case.
\l   Convert the first character of the next &amp; or \# to lower case.

These may be preceded by a backslash to force them to be treated normally.

If nomagic  mode is in effect,  then &amp; and ~  will be treated normally,
and you must write them as \&amp; and \~ for them to have special meaning.

Preserving Text

Should elvis  sense that it  is about to  die unexpectedly, it  invokes the
command elvprsv to save the temporary file in which it manipulates the file
you are editing.  To recover this  saved file, use the command elvrec. Both
commands are described in the Lexicon.

Initialization Files

When you invoke  elvis, it searches for file $HOME/.exrc.  If it finds that
file, it reads the file and attempts to execute its contents as a series of
ex  commands.  (As  noted earlier,  ex  commands simply  are elvis'  set of
colon-mode commands, but without the preceding colon.)

Usually, this  file is used  to contain instances  of the commands  set and
color,  to set  up elvis'  environment and appearance  to your  taste.  For
example, if your .exrc file contains the commands

    color white on blue
    set ignorecase
    set inputmode

then elvis  sets the screen's  background color to blue  and its foreground
color  to white;  turn on  ignorecase mode (that  is, string  searches will
ignore case), and come up in input mode rather than command mode.

The file $HOME/elvis.rc is a synonym for $HOME/.exrc.

When you  invoke elvis, it also searches for  the file $HOME/.exfilerc This
file holds ex commands that elvis  executes every time it loads a text file
for editing.  You can embed if  commands in this file so that elvis handles
special classes of files uniquely.  For  example, you can use an if command
to tell  elvis to handle  files with the  suffix .c differently  from other
files; this lets you invoke special editing functions for C programs.

Examples

The first example changes every occurrence of ``utilize'' to ``use'':

    :%s/utilize/use/g

The next example  deletes all white space that occurs  at the end of a line
anywhere in  the file.  (The brackets  contain a single space  and a single
tab character):

    :%s/[   ]+$//
The next example converts the current line to upper case:

    :s/.*/U&/

The next example underlines each letter in the current line, by changing it
into  an  underscore backspace  letter  sequence.   (The <ctrl-H>  is
entered as <ctrl-V><backspace>):

    :s/[a-zA-Z]/_^H&/g

The  last example  locates the  last colon  in a line,  and swaps  the text
before  the  colon with  the  text  after the  colon.   The  first pair  of
parentheses  delimits  the stuff  before  the colon,  and  the second  pair
delimits the stuff after.  In the substitution text, \1 and \2 are given in
reverse order to perform the swap:

    :s/\(.*\):\(.*\)/\2:\1/

Environment

elvis reads the following environmental variables:

TERM This names your terminal's entry in the termcap or terminfo data base.

TERMCAP
     Optional.  If  your system uses  termcap, and the  TERMCAP variable is
     not   set,  then   elvis   reads  your   terminal's  definition   from
     /etc/termcap.  If TERMCAP  is set  to  the full  path name  of a  file
     (beginning with a `/'),  it reads your terminal's description from the
     named file instead of from /etc/termcap.  If TERMCAP is set to a value
     that does not  begin with a `/', then elvis  assumes that its value is
     the full termcap entry for your terminal.

TERMINFO
     Optional.  elvis  treats this exactly like  the environmental variable
     TERMCAP, except for the terminfo data base.

LINES
COLUMNS
     Optional.  These  variables, if  set, override the  screen-size values
     given  in the  termcap  or terminfo  description of  your terminal  On
     windowing systems  such as  X, elvis has  other ways to  determine the
     screen size, so you should probably leave these variables unset.

EXINIT
     Optional.   This variable  can hold  ex  commands that  elvis executes
     before it reads any .exrc files.

SHELL
     Optional.  This variable sets  the default value for the shell option,
     which determines  which shell program  elvis uses to  perform wildcard
     expansion in file names,  and to execute filters or external programs.
     The default value is /bin/sh.

HOME This variable should be set to the name of your home directory.  elvis
     looks for  its initialization  file there.  If  HOME is not  set, then
     elvis does not execute the initialization file.

TAGPATH
     Optional.  This  variable is  used by the  program ref. See  "ref" for
     more information.

Bug Fixes from Release 1.7

Beginning with release 4.2.10, COHERENT includes elvis release 1.8pl3.  The
following describes the bugs that this release fixes The initial release of
elvis 1.8 includes the following bug fixes:

-> Most screen update bugs are fixed.  Most of ones that were not fixed can
   be avoided by :set nooptimize.

-> A bug in  the visual `@' command was fixed.   This bug can be blamed for
   most of elvis' incompatibility with fancy macro packages.  elvis can now
   run the  ``Bouncing Ball,''  ``Word Completion,'' and  ``Turing'' macros
   with no changes.  NB, it still cannot run ``Towers of Hanoi.''

The following bug fixes are included in patch-level 1 (pl1):

-> Fixed a bug  that caused core dump when you  use the `}' command used on
   blank line after last paragraph in file.

-> Fixed a bug  that caused loss of text with  AutoIndent enabled, when two
   newlines are inserted into the middle of a line.

The following bug fixes are included in patch-level 2 (pl2):

-> Fixed a security hole on some UNIX systems.

-> After :w, # refers to the file just written.

-> Fixed bug in tag lookup.

-> The compiler error parser now allows `_' in a file name.

-> Fixed  a bug  that  caused some  blank  lines in  the file  .exrc to  be
   interpreted as :p commands.

-> Increased the limit on word size for the command <ctrl-A>. The old
   limit was 30; the new limit is 50.  If you exceed this limit, elvis will
   now search  for the longest  possible substring; before,  it would bomb.
   To change the limit, add -DWSRCH_MAX=n  (where n gives the limit on word
   size) to CFLAGS in the Makefile, then recompile elvis.

-> Increased the size of an  array used while showing option settings.  The
   old size could overflow if you did a :set all on some systems.  Now, the
   maximum size is calculated at compile time, and the array is declared to
   this size.

-> The command  5r<ctrl-M> now leaves the cursor  in the right place.
   In earlier releases, 5r<ctrl-M> would replace five characters with
   five newline characters, and leave the cursor five lines lower.  Release
   1.8 replaced  five characters with a single  newline character, to mimic
   the real  vi better, but still  left the cursor five  lines lower.  This
   patch finally makes it right.

The following bug fixes are included in patch-level 2 (pl2):

-> Corrected bugs  in :tag and :make, which caused  tag addresses and error
   messages to  be forgotten after switching  files.  The .exfilerc feature
   interacted with  these bugs, and made them  pretty obnoxious.  A similar
   bug caused  the command :e +cmd  file to start misbehaving;  it has been
   fixed, too.

-> The option window now defaults to  zero.  Zero is a special value, which
   means  ``use  as  many  rows  as  possible.''  Previously,  this  option
   defaulted to  the maximum  number of  rows available when  elvis started
   (usually 24), which resulted in `@' signs appearing on the screen if you
   resized the  display while elvis was running.   This problem only showed
   up when you ran elvis in an X terminal window.

-> A bug has been fixed  in autoindentation.  Previously, if you inserted a
   newline  before  the  first non-whitespace  character  on  a line,  then
   everything after the insertion  point was wiped out.  (This is different
   from the  bug that pl2 fixed.   pl2's fix addresses a  bug that affected
   insertion of  multiple newlines  anywhere in  a lines; this  one affects
   inserting a single newline before the first non-whitespace character.)

-> To avoid  linking problems on various systems, the  variable kD has been
   renamed kDel, and function ioctl() in pc.c renamed elvis_ioctl.

-> A bug that caused :! to  clobber the value of # (i.e., the previous file
   name) has been fixed.

-> There is a  bug that affects screen redraws after  pasting (the visual p
   and P  commands).  In  an attempt  to work around  this bug,  elvis will
   sometimes redraw the screen from scratch after a multi-line paste.

-> Some people  have reported  problems using  fmt on non-English  text.  I
   suspect that this is due to  a faulty implementation of isspace() in the
   standard  C library.   In  release 1.8pl3,  fmt does  not use  isspace()
   anymore;  it   uses  a  built-in   macro  which  explicitly   tests  for
   <space> or <tab>. This may solve the problem.

Files

/tmp/elv* -- Temporary files
tags -- Data base used by the tags command
$HOME/.exrc -- File that sets personal defaults
$HOME/.exfilerc -- File that sets defaults when a file is read
$HOME/elvis.rc -- Same as .exrc

See Also

commands,
ed,
elvprsv,
elvrec,
ex,
fmt,
me,
vi,
view

Notes

elvis returns zero if the file being edited was updated.  It returns one if
the  file was  not  updated, and  a  different nonzero  value  if an  error
occurred.

Full documentation  for elvis is  included with this  release in compressed
file /usr/src/alien/Elvis.doc.Z.

elvis  is copyright  © 1990  by Steve Kirkendall,  and was  written by
Steve             Kirkendall            (kirkenda@cs.pdx.edu             or
uunet!tektronix!psueea!eecs!kirkenda), assisted by numerous volunteers.  It
is freely  redistributable, subject to  the restrictions noted  in included
documentation.   Source  code  for  elvis  is  available through  the  Mark
Williams bulletin board, USENET, and numerous other outlets.