elvis
Visual interface editor clone (UNIX)
Syntax:
elvis [options]... [+command] file...
Runs on:
QNX OS
Options:
- -a
- Create a separate window for each file.
- -B blksize
- Use blocks of size blksize.
- -b
- Mark new buffers as readeol=binary.
- -c command
- Begin editing by executing this ex command.
- -e
- Start up in colon (ex) command mode.
- -f session
- Use session as the session file.
- -G gui
- Use the gui user interface:
- termcap — termcap/terminfo interface with windows and color (the default)
- open — generic interface with limited capabilities
- script — read a script from stdin
- quit — quit immediately after processing -c cmd
- ? — list the available user interfaces
- -i
- Start up in input mode.
- -o logfile
- Send messages to logfile instead of to stderr.
- -R
- Set read-only mode to prevent accidental overwriting of files.
- -r
- Restart a session after a crash.
- -S
- Set security=safer, to protect against Trojan horses.
- -SS
- Set security=restricted, for maximum security.
- -s
- Read a script from stdin and execute it.
- -V
- Be verbose; give more status information.
- -w lines
- Set the scroll amount to lines.
- +command
- Begin editing by executing this ex command.
- file
- A pathname of a file to be edited.
Description:
The elvis utility is an interactive fullscreen editor that is compatible with the Unix/POSIX vi editor. The vi utility in the QNX OS is a link to elvis.
In elvis, changes are buffered and are written to the file only upon request. Since a temporary file is used for storage, elvis can edit files larger than the amount of memory available on the machine it's run on.
There are two major command modes:
- visual mode
- ex mode (also known as colon mode)
You can switch between modes. You'll probably use the visual command mode most of the time. This is the mode elvis normally starts up in.
In visual mode, the entire screen is filled with lines of text from
your file (except the last screen line, which is reserved for status).
You can view text and move around the file. Each keystroke is interpreted
as part of a visual command. If you start typing text, it isn't
inserted; instead, it's treated as part of a command. To insert
text, you must first give an insert text
command (see Inserting text
).
The ex mode is quite different.
In this mode, elvis displays a
character on the bottom line of
the screen as a prompt. You are then expected to type in a command
and press Enter. The set of commands recognized in
ex mode differs from those in visual mode, and are known as
ex commands. A summary of these commands is found at the end
of this description. (A line-oriented editor,
ex is a predecessor of vi, and the
two share common functionality.)
:
The capabilities of elvis are described throughout the following sections:
- Visual mode
- Movement commands
- Inserting text
- Deleting, yanking, putting
- Filters
- Shifting text
- Miscellaneous commands
- Searching
- Global & substitute commands
- Undo and retrieving
- Screen commands
- Writing files
- Editing other files
- Reading in a file
- Leaving elvis
- Escaping to a shell
- Macros
- Abbreviations
- Options
- ex commands
Visual mode
Most visual mode commands are one keystroke long. The following sections list the operation performed by each keystroke, and any necessary options or operands.
Most commands may be preceded by a decimal number. Usually, this number specifies how many times the command is to be repeated. Without this number, the command in most cases executes just once.
Input mode
You can't enter text into your file directly from visual command mode. Instead, you must first give a command that puts you into input mode. The commands to do this are:
A, C, I, O, R, S,
a, c, i, o, s
Note that if the showmode option is set (this option
described in the Options
section below), the mode is
displayed in the lower right-hand corner as either Command
or Input
. Also note that each mode uses a different cursor
shape.
Operators
Among its various commands, elvis has seven basic but powerful operators that let you change, delete, cut, paste, shift, or filter text regions. Although they're described below in the appropriate sections, you should note that, for the most part, they all share a common form:
op<object>
where op can be:
- c
- Change
- d
- Delete
- y
- Yank (copy)
- >
- Shift right
- <
- Shift left
- !
- Filter
One operator doesn't take an object:
- p
- Put
The object operand specifies the range of
text that the op operator acts upon. The
object can be any movement command or pattern search.
(See Movement commands.
)
In this way, you can see the power of the operators.
The elvis utility can act on words, sentences, regions
up to a specified pattern — whatever range the object operand specifies.
When you give a movement command as an operand, you can specify an optional count [n] to multiply the effect of the operand (e.g. d2w to delete next two words). When a count isn't provided, it typically defaults to 1.
Special cases
Operators are frequently used with lines. So, for simplicity, a few special forms of these commands operate only with line objects. The following list shows the syntax of these special forms. Note the count is optional, and precedes the operator (this differs from the above form):
- [n]cc
- Change n lines
- [n]dd
- Delete n lines
- [n]Y or [n]yy
- Yank n lines
- [n]<<
- Shift n lines to the left
- [n]>>
- Shift n lines to the right
Named buffers
When you yank, delete, change, shift, or filter text, elvis
saves the affected region in a single unnamed cut buffer, which you
can recall by the p (put) command. However, elvis
also has 26 named buffers, a
to z
, that
you can use to save blocks of text during an editing session. These buffers
are often used when editing multiple files to move text around.
You can prefix the previously defined operator forms by
"a through "z (represented below by "<a-z
>)
to indicate which cut buffer to use to store the modified
text region:
- "<
a-z
>op<object> - Normal cases.
- "<
a-z
>[n]op - Special cases.
When you use the uppercase letters to denote the named buffers, the objects are appended to the buffer:
- "<
A-Z
>op<object> - Normal cases.
- "<
A-Z
>[n]op - Special cases.
Movement commands
The following movement commands provide a convenient means to position
the cursor throughout the file being edited.
You can precede most by an optional count to repeat the action.
More importantly, you can use these movement commands as operands to the
change, yank, delete,
put commands to specify the range of action to be performed (see Inserting
text
and Deleting, yanking, putting
sections).
The movement commands operate on the following text objects:
- Character
- A single character.
- Sentence
- A sequence of text ending in one of the following characters, followed by two spaces or a newline:
. ! ?
- Paragraph
- A paragraph starts after an empty line or any of the pairs of characters defined with the :set pa= option are found.
- Section
- A section starts where any of the pairs of characters defined with the :set se= option are found.
Cursor movement
To move the cursor, you can use the keypad arrow keys; you can also use the H, J, K, and L keys.
- [n]j or [n]down-arrow or [n]CtrlJ or [n]CtrlN
- Move down n lines (next).
- [n]k or [n]up-arrow or [n]CtrlP
- Move up n lines (previous).
- [n]l or [n]right-arrow or [n]Space
- Move right n characters.
- [n]h or [n]left-arrow or [n]Backspace
- Move left n characters.
- [n]-
- Move to first nonblank character on nth line, in backward direction.
- [n]+
- Move to first nonblank character on nth line, in forward direction.
- [n]$
- Move to the end of the line.
- ^
- Move to the beginning of the first word on the line.
- 0
- Move to the left margin (first nonblank character) of current line.
- [n]|
- Move to the column specified by n.
- [n]w
- Move to the beginning of the next word.
- [n]W
- Move to the beginning of the next word that follows white space.
- [n]b
- Move to the previous word.
- [n]B
- Move to the previous word that's delimited by white space.
- [n]e
- Move to the end of the word.
- [n]E
- Move to end of the word that's delimited by white space.
- [n]G
- Move to the specified line (default is last line of file for a single G command).
- [n]f<char>
- Move to the nth occurrence of char (in forward direction) on the current line. The cursor is placed at the matched character.
- [n]F<char>
- Move to the nth occurrence of char (in backward direction) on the current line. The cursor is placed at the matched character.
- [n]t<char>
- Move to the nth occurrence of char (in forward direction) on the current line. The cursor is placed just before the matched character.
- [n]T<char>
- Move to the nth occurrence of char (in backward direction) on the current line. The cursor is placed just before the matched character.
- [n];
- Repeat previous f, F, t, or T command, in the same direction.
- [n],
- Repeat previous f, F, t, or T command, in the opposite search direction.
- %
- Move to matching parenthesis, bracket, or brace; i.e.:
( ) [ ] { }
- [n])
- Move to the beginning of the next sentence.
- [n](
- Move to the beginning of the current sentence.
- [n]}
- Move to the beginning of the next paragraph.
- [n]{
- Move to the beginning of the current paragraph.
- [n]]]
- Move to the beginning of the next section.
- [n][[
- Move to the beginning of the current section.
- [n]H
- Move to the top left position of screen. If n is specified, move the cursor to the beginning of the line n lines from the top of the screen.
- [n]L
- Move to the beginning of the last line on screen. If n is specified, move the cursor to the beginning of the line n lines from the bottom of the screen.
- M
- Move to the beginning of the middle line on the screen.
Marking
- m<a-z>
- Mark the current position with the character <a-z>.
- '<a-z>
- Move to the beginning of the marked line.
- `<a-z>
- Move to the exact position marked with the character <a-z>.
- ''
- Move back to the beginning of the line where it was before the last
nonrelative
move. - ``
- Move back to the exact position it was before the last nonrelative move.
Inserting text
The following commands enter input mode, where the text you enter (until you press Esc) is put into the file:
- a
- Append text after the current cursor position.
- A
- Append text at the end of current line.
- i
- Insert text before the current cursor position.
- I
- Insert text at beginning of current line.
- o
- Open a new line below line cursor is on, insert text there.
- O
- Open a new line above line cursor is on, insert text there.
- c<object>
- Change the text between the current position and the position
specified by the <object> (movement operand or pattern).
You can specify an optional count to multiply the effect
of the <object> operand (e.g. c2w to change next two words).
If the range is within the current line, a
$
is displayed at the end of the <object> to indicate end-of-range. Otherwise, the text in the range is deleted and you're placed in input mode. When within a line, the specified range of text isn't deleted until you type Enter. - [n]cc
- Change n lines.
- R
- Replace the rest of the line with text. Rather than delete the text as with the change command, before going into insert mode, all text entered overwrites the current line until it has been completely replaced; at that point you're placed in input mode.
- s
- Substitute text for the current character (abbreviation for cl).
- S
- Substitute text for the current line (abbreviation for cc).
Input mode
In input mode, all keystrokes are inserted into the text at the cursor's position, except for the following:
- Esc or Ctrl[
- Exit from input mode, back to command mode.
- INTR
- Interrupt execution (usually CtrlC, see stty).
- erase or CtrlH
- Erase the character before the cursor.
- CtrlW
- Erase the last input word.
- CtrlA
- Insert a copy of the last input text.
- CtrlD
- Delete one indentation character.
- CtrlL
- Redraw the screen.
- CtrlM or Enter
- Insert a newline.
- CtrlP
- Insert the contents of the cut buffer.
- CtrlR
- Redraw the screen (like CtrlL).
- CtrlT
- Insert an indent character.
- CtrlU
- Backspace to the beginning of the line.
- CtrlV
- Insert the following keystroke, even if special (e.g., CtrlV CtrlL inserts a form-feed).
Deleting, yanking, putting
As mentioned in the introduction, elvis supports very powerful operator constructs. In this section we describe the delete, yank, and put operators.
- Delete
- Delete the specified region and place the text into the unnamed buffer, or a named buffer if one is specified.
- Yank
- Make a copy of the specified region and place it into the unnamed buffer, or a named buffer if one is specified.
- Put
- Put the contents of the unnamed buffer, or of the named buffer if specified, into its new location.
When you have a sequence of text you want to copy or move to a different location, you first use the yank or delete operators to copy or delete the data into a buffer; you then use the put command to place the data at its new location.
If you're using named buffers, you can switch to another file before putting the text back. Thus you can copy from one file to another.
To copy the next four lines, yank them with a command such as 4yy or y4j, move to a new location and put the text by typing the p command.
To delete the next four lines, type 4dd or d4j.
To move the next four lines, use a command such as 4ddor d4j, then move to a new location and put the text by typing p or :pu.
Filters
With the filter command, you can select regions of text and run them through any command and insert the output into the file. The text in the range specified from the current line to the delimited <object> is filtered through the command and replaces the region specified. The text that was in the region before being replaced by the output of the command is saved in the unnamed buffer, or in a named buffer if one was specified. If uppercase letters are used, elvis appends text to the named buffer.
- !<object>command
- Delete the specified text object into a buffer (unnamed, or named if given). Pass the specified text region to the standard input of the command, and replace it with the command's output. When you enter this command, the ! prompt doesn't appear until an <object> has been given.
Shifting text
The shift operators, < and >, shift all the lines delimited by the current line and the <object> operand. Text is shifted by the value of the shiftwidth option (see below). The forms of the shift command are:
- ><object>
- Shift <object> to the right.
- <<object>
- Shift <object> to the left.
- [n]>>
- Shift next n lines to the right.
- [n]<<
- Shift next n lines to the left.
Miscellaneous commands
- [n].
- Repeat last text modifying command n times.
- [n]r<char>
- Replace current character with char.
- D
- Delete to the end of the line (abbreviation for d$)
- [n]J
- Join the next line with the current line.
- :[x,y]j
- Join all the lines in the specified range.
- [n]x
- Delete n chars, to the right, including cursor position.
- [n]X
- Delete n chars to the left of the cursor.
- [n]~
- Reverse the case of the n next characters.
- :[x,y]p
- Display text in the specified range.
- :[x,y]l
- Display text in the specified range with tab and end-of-line markers.
- :[x,y]nu
- Display text in the specified range, with line numbers.
- :so file
- Read and execute the commands listed in file.
- :ve
- Display version number and compilation date of elvis.
Searching
A pattern used for searching and substituting is called a regular
expression. While most characters match themselves in a search
request, some have special meaning, as described in the table below.
To be used in a search expression, these special characters must be preceded by a backslash (\
).
Character | Meaning |
---|---|
^ | Match beginning of line. |
$ | Match end of line. |
. | Match any single character except the newline. |
\< | Match the beginning of a word. |
\> | Match the end of a word. |
[string] | Match any single character in string. |
[^string] | Match any single character not in string. |
[x-y] | Match any character between x and y (range). |
[^x-y] | Match any character not between x and y (range). |
* | Match any repeated characters. |
\ | Escape special characters. |
The commands for searching are as follows:
- /[pattern]Enter
- Search forward for pattern.
- ?[pattern]Enter
- Search backward for pattern.
- /[pattern]/{+|-}nEnter
- Go to the nth line relative to the line on which pattern is found, in forward direction.
- ?[pattern]?{+|-}nEnter
- Go to the nth line relative to the line on which pattern is found, in backward direction.
- /Enter
- Repeat the previous pattern search, in forward direction.
- ?Enter
- Repeat the previous pattern search, in backward direction.
- n
- Repeat the previous pattern search.
- N
- Repeat the previous pattern search, in reverse direction.
For example, to match fred1
, fred2
, or fred3
:
/fred[1-3]
To match Realtime OS
at the beginning of a line:
/^Realtime OS
To match Realtime OS
at the end of a line:
/Realtime OS$
Global & substitute commands
The global and substitute commands can operate over a range of lines. You can specify a range wherever [x,y] is indicated. The first element, x, indicates the first line of the range, and the second element, y, indicates the last line. You can use line numbers or any of the following special characters as range elements:
- .
- The current line.
- $
- The last line in the file.
- %
- Same as 1,$ (i.e., the entire file).
- n
- Relative offset from current line.
A range element may also be a pattern specification:
/pattern/
or a marked location:
'<a-z>
For example, to print the lines from the next line containing steve
until the first subsequent blank line:
/steve,/^$/!lp
Substitute command
The substitute command substitutes text matching a pattern with replacement text:
:[x,y]s/pattern/replacement_text/[c][g][p]
If none of the modifiers c, g, or p is specified, this command replaces the first occurrence of the given pattern. You can modify this behavior by specifying any combination of the three modifiers:
- c
- Prompt before replacing.
- g
- Replace all matched occurrences on a line.
- p
- Display all lines containing the replaced text.
This command is very powerful when used in conjunction with the global command (see below).
Global command
The global command searches through the lines of the specified range—or through the whole file if no range ([x,y]) is specified—for lines that contain the pattern. The command is performed on each matching line. The global command is of the following form:
- :[x,y]g/pattern/command
- Execute command for every line that matches pattern.
- :[x,y]g!/pattern/command or :[x,y]v/pattern/command
- Execute command for every line that doesn't match pattern.
You can combine the substitute and global commands, using the following syntax:
[x,y]g/pattern/s//replacement_text/
This command runs the substitute command on every occurrence of a matched pattern within the given range. The null pattern specification (i.e. //) indicates to the substitute command that it's to use the currently matched global pattern as the text it's to replace.
The following variations may also be used:
[x,y]g!/pattern/s//replacement_text/
[x,y]v/pattern/s//replacement_text/
For example, substitute the word fred
with the word barney
in lines 1 to 10:
1,10g/fred/s//barney
Match every mary
that's at the beginning of a line and
prompt the user to confirm the substitution:
1,$g/^mary/s//dave/c
Undo and retrieving
On occasion, you need to undo the effects of a command:
- u
- Undo the effects of the last command that changed the edit buffer.
- U
- Undo the effects of all the text modifying commands performed on this line. Return the line to its original state.
The editor saves the last nine deleted blocks of text in save buffers. You can retrieve a buffer with the following commands:
- "np
- Retrieve nth previous deletion (1-9). Place after the cursor.
- "nP
- Retrieve nth previous deletion (1-9). Place before the cursor.
If you accidentally select the wrong buffer, you can use the undo command to clear it and then try specifying a different buffer.
You can also use named buffers (see
Deleting, yanking, putting
):
- "<
a-z
>p - Retrieve the contents of the named buffer. Place after the cursor.
- "<
a-z
>P - Retrieve the contents of the named buffer. Place before the cursor.
Screen commands
The scrolling commands are as follows:
- [n]CtrlD
- Scroll down n lines (default is half page). n is remembered and becomes the default.
- [n]CtrlU
- Scroll up n lines (default is half page). n is remembered and becomes the default.
- [n]Pg Dn or [n]CtrlF
- Jump forward n pages.
- [n]Pg Up or [n]CtrlB
- Jump backward n pages.
- [n]CtrlE
- Scroll down n lines.
- [n]CtrlY
- Scroll up n lines.
To position the current line at different positions on the screen by scrolling forward/backward:
- z.
- Place line at center of screen.
- z-
- Place line at bottom of screen.
- CtrlL or CtrlR
- Redraw the screen.
The status commands are as follows:
- CtrlG or :f
- Display status line on bottom of screen.
Writing files
The following commands write to a file. You can precede all w commands by an [x,y] range. For example, specify 1,6w to write the first 6 lines.
- :w
- Write changes to current file.
- :w file
- Write changes to file.
- :w >>file
- Append changes to file.
- :w! file
- Force write to file.
- :wq
- Write the file and exit.
- ZZ OR :x
- Exit elvis. If any changes were made, the edit buffer is written to the file.
Editing other files
- :e file
- Edit file.
- :e!
- Re-edit current file, discarding unsaved changes.
- :e! file
- Edit file, discarding unsaved changes to the current file.
- :e +n file
- Edit file, start at line n.
- :e # or Ctrl^
- Return to the previous position in the last edited file.
- :n
- Edit the next file in the argument list.
- :n!
- Edit the next file, discarding unsaved changes to the current one.
- :n args
- Use this new argument list.
- :args
- Show list of files,
[]
indicate current file. - :rew
- Rewind list of files, re-edit first file.
- :rew!
- Rewind the list of files, re-edit the first file, and discard any unsaved changes to the current file.
Reading in a file
- :r file
- Read in file after the cursor.
- :nr file
- Read in file after line n.
- :r !cmd
- Read in the output of the named command.
Leaving elvis
- ZZ or :x
- Exit elvis. If any changes were made, the edit buffer is written to the file.
- :wq
- Write the file and exit.
- :q
- Exit from elvis.
- :q!
- Exit from elvis and discard any unsaved changes.
- :Q
- Escape to the ex line editor (to return, type elvis).
Escaping to a shell
To execute a single command from within elvis, you can use the following command:
- :!cmd
- Execute a single command, then return to elvis.
To execute more than one command, you can create a shell:
- :sh
- Start a subshell. You can type CtrlD or exit to return to elvis.
Macros
Macros let you bind a single key to an arbitrary set of editing commands.
Defining a macro is simple: you define an lhs (left-hand side), which is the single character you want translated, followed by an rhs (right hand side), which is the sequence it is mapped into.
- :map lhs rhs
- Create a macro.
- :unmap lhs
- Delete macro.
- :map
- Display macros.
For example, :map q :wqCtrlVEnterEnter maps q into :wqEnter. The CtrlV is needed to quote (escape) the first Enter, while the second Enter ends the map definition.
Abbreviations
Word abbreviations are similar to macros, but they expand a short word into a longer word or words. If you type the abbreviation as part of a longer word, it's left alone. Abbreviations are used in input mode primarily to save typing.
Substitution isn't performed until you type a nonalphanumeric character to mark the end of the word. If you type CtrlV before the nonalphanumeric character, elvis doesn't perform the substitution.
- :ab abbr replacement_text
- Create an abbreviation.
- :ab
- Display abbreviations.
- :una abbr
- Turn off this abbreviation.
For example:
:ab woof mary had a little ram
This inserts the text mary had a little ram
whenever the word woof
is typed.
Options
You can set or examine options via the colon command set. The values of options affects the operation of subsequent commands.
There are three option types:
- those that toggle on or off; these are enabled by typing :set option and disabled by typing :set nooption.
- those that expect a numeric value
- those that expect a string value; these are used by typing :set option=value
To print all the option settings, type:
:set all
For convenience, options have both a long descriptive name and a short name (shown in parentheses below) that's easier to type. You may use either interchangeably.
- autoindent (ai)
- Default: noai
In input mode, if autoindent is on, each added line begins with the same amount of leading white space as the line above it. Without autoindent, added lines begin at column zero.
- autoprint (ap)
- Default: ap
This option affects only ex mode. If this option is on, and either the cursor has moved to a different line or the previous command modified the file, elvis prints the current line.
- autowrite (aw)
- Default: noaw
If you've made modifications to the current file then try switching to another file, (e.g.:next...), elvis normally prints an error message and refuses to switch. If this option is on, elvis writes the modified version of the current file and switches to the new file.
- directory (dir)
- Default: dir="/tmp"
elvis stores text in temporary files. This option lets you control which directory those temporary files appear in. The default is /tmp.
You can set this option only in a .exrc file; once elvis is started, the directory can't be changed.
Note:If your /tmp directory is on ramdisk, recovery isn't possible if the system is rebooted. - edcompatible (ed)
- Default: noed
Remember :s// options.
- errorbells (eb)
- Default: eb
The elvis utility normally rings a bell when you do something wrong. This option lets you disable the bell.
- ignorecase (ic)
- Default: noic
Normally, when elvis searches for text, it distinguishes between uppercase and lowercase letters. When this option is on, uppercase and lowercase are seen as equivalent.
- list (li)
- Default: noli
In nolist mode (the default), elvis displays text in a
normal
manner—with tabs expanded to an appropriate number of spaces, etc. However, sometimes it's useful to have tab characters displayed differently. In list mode, each tab is displayed as^I
, and a$
is displayed at the end of each line. - magic (ma)
- Default: ma
The search mechanism in elvis can accept regular expressions—strings in which certain characters have special meaning. The magic option is normally on, which causes these characters to be treated specially. If you turn the magic option off (:set noma), then all characters except
^
and$
are treated literally. Both^
and$
retain their special meanings regardless of the setting of magic. - paragraphs (pa)
- Default: pa="PPppIPLPQP"
The { and } commands move the cursor forward or backward in increments of one paragraph. Paragraphs may be separated by blank lines or by a leading
dot
command of a text formatter. Different text formatters use different dot commands. This option lets you configure elvis to work with your text formatter.It's assumed your formatter uses commands that start with a
.
character at the front of a line, followed by a one- or two-character command name.The value of the paragraphs option is a string in which each pair of characters is one possible form of your text formatter's paragraph command. For example, lines starting with
.IP
,.LP
, or.PP
are considered new paragraphs. - readonly (ro)
- Default: noro
Prevent overwriting of original file. Normally, elvis lets you write back any file for which you have write permission. If you don't have write permission, all you can do is write the changed version of the file to a different file.
If you set the readonly option, elvis pretends you don't have write permission to any file you edit. This is useful when you mean to use elvis only to look at a file, not to change it. This way, you can't change the file accidentally.
This option is normally off, unless you use the view alias of elvis, which is like elvis except the readonly option is on.
- report (re)
- Default: re=5
Changes, deletes, and yanks may affect many lines. For commands affecting a lot of lines, elvis outputs a message saying what was done and how many lines were affected. This option lets you define what
a lot of lines
means. The default is 5, so a message is shown on the status line for any command affecting 5 or more lines. - scroll (sc)
- Default: sc=12
Scroll amount for CtrlU and CtrlD. These commands normally scroll backward or forward by half a screenfull, but you can adjust this. The value of this option says how many lines those keys should scroll. You can also set this with [n]CtrlD and [n]CtrlU.
- sections (se)
- Default: se="NHSHSSSEse"
The [[ and ]] commands move the cursor backward or forward in increments of one section. Sections may be delimited by a { character in column 1 (which is useful for C source code) or by means of a text formatter's
dot
commands.This option lets you configure elvis to work with your text formatter's section command, in exactly the same way that the paragraphs option makes it work with the formatter's paragraphs command. For example, lines starting with
.SH
or.NH
are considered new sections. - shell (sh)
- Default: sh="/bin/sh"
When elvis forks a shell (perhaps for the :! or :sh commands), this is the program it uses as a shell. The normal default is /bin/sh. However, if you have set the SHELL environment variable, the default value is copied from the environment.
- shiftwidth (sw)
- Default: sw=8
The < and > commands shift text left or right by a uniform number of columns. The shiftwidth option defines that uniform number. The default is 8 spaces.
- showmatch (sm)
- Default: nosm
With showmatch set, every time you type
)
,}
, or]
in input mode, elvis momentarily moves the cursor to the matching opening parenthesis or bracket. - showmode (smd)
- Default: nosmd
In visual mode, it's easy to forget whether you're in the visual command mode, or input/replace mode. Normally, the showmode option is off, and you aren't informed as to which mode you're in. If you turn the showmode option on, a message appears in the lower right corner of your screen, telling you which mode you're in.
- tabstop (ts)
- Default: ts=8
The width of tab characters.
- term (te)
- Default: te="$TERM"
This read-only option shows the name of the terminal entry that elvis is using for your terminal.
- warn (wa)
- Default: wa
If you've modified a file, but not yet written it back to disk, elvis normally prints a warning before executing a :!cmd" command. However, in nowarn mode, this warning isn't given.
Normally, elvis also prints a message after a successful search that wrapped at EOF. The [no]warn option also disables this warning.
- wrapmargin (wm)
- Default: wm=0
Wrap long lines in input mode. Normally (with wrapmargin=0), elvis lets you type in extremely long lines.
However, with wrapmargin set to something other than 0 (wrapmargin=70 is nice), long lines are automatically
wrapped
on a word break for lines longer than wrapmargin's setting. - wrapscan (ws)
- Default: ws
Normally, when you search for something, elvis finds it no matter where it is in the file. elvis starts at the cursor position, and searches forward. If elvis reaches EOF without finding what you're looking for, it wraps around to continue searching from line 1, up to the current line.
If you turn off the wrapscan option (:se nows), and elvis subsequently reaches EOF during a search, it stops and says so.
EXINIT="set ai aw"
export EXINIT
ex commands
The following list of ex commands is intended for your convenience only. It's beyond the scope of this document to describe the operations of these commands in detail. Most of these commands have been indicated as alternatives to the visual mode commands described in the above sections.
The general form of these commands is:
:[x,y] command parameter
[Prefix] | Command | Short form |
---|---|---|
abbrev abbr text | ab | |
[line] | append | a |
args | ar | |
[x[,y]] | change | c |
[x[,y]] | copy line | co |
[x[,y]] | delete ["named_buffer] | d |
edit[!] file | e | |
file | f | |
[x[,y]] | global /pattern/command/ | g |
[line] | insert | i |
[x[,y]] | join | j |
[x[,y]] | list | l |
map lhs rhs | map | |
[x[,y]] | move line | m |
next[!] | n | |
[x[,y]] | number | nu |
[x[,y]] | p | |
[line] | put ["named_buffer] | pu |
quit[!] | q | |
[line] | read file | !command | r |
rewind[!] | rew | |
set [option] | se | |
shell | sh | |
source file | so | |
[x[,y]] | substitute /pattern/text/[c][g][p] | s |
unabbrev abbr | una | |
undo | u | |
unmap lhs | unm | |
version | ve | |
visual | vi | |
[x[,y]] | write[!][[>>]file] | w |
xit[!] | x | |
[x[,y]] | yank ["named_buffer] | ya |
The following ex commands have no long version:
Command | Form |
---|---|
escape | !command |
print next | CR |
lshift | < |
rshift | > |
See also:
Linda Lamb, Learning the vi Editor, O'Reilly and Associates, 1990
Files:
- /tmp/elv*
- During editing, text is stored in a temporary file in /tmp.
- $HOME/.exrc
- On startup, the contents of this file are executed as a series of ex commands.
Environment variables:
- LINES, COLUMNS
- Overrides the screen size values associated with your terminal type.
- EXINIT
- Default elvis option settings. If set, the contents of this environment variable are executed on startup as a series of ex commands.
export TERM=qansi
or:
export TERM=qnx
depending on the mode your console is running in (QNX vs ANSI).
Contributing author:
Steve Kirkendall
Caveats:
When displayed, long lines scroll horizontally. On some implementations, these wrap onto multiple rows on the screen.
Under QNX OS, you must have a /tmp directory for temporary files. To use a RAM disk as /tmp, try this:
ln -sP /dev/shmem /tmp