Execute cmd immediately after starting the edit session. Particularly useful for initial positioning in the file, however cmd is not limited to positioning commands. This is the POSIX 1003.2 interface for the historic +cmd syntax. Nex/nvi supports both the old and new syntax.
-e
Start editing in ex mode, as if the command name were ex.
-F
Dont copy the entire file when first starting to edit. (The default is to make a copy in case someone else modifies the file during your edit session.)
-l
Start editing with the lisp and showmatch options set.
-G
Start editing in gtags mode, as if the gtagsmode option was set.
-R
Start editing in read-only mode, as if the command name was view, or the readonly option was set.
-r
Recover the specified files, or, if no files are specified, list the files that could be recovered. If no recoverable files by the specified name exist, the file is edited as if the -r option had not been specified.
-S
Run with the secure edit option set, disallowing all access to external programs.
-s
Enter batch mode; applicable only to ex edit sessions. Batch mode is useful when running ex scripts. Prompts, informative messages and other user oriented message are turned off, and no startup files or environment variables are read. This is the POSIX 1003.2 interface for the historic - argument. Nex/nvi supports both the old and new syntax.
-t
Start editing at the specified tag. (See ctags(1)).
-w
Set the initial window size to the specified number of lines.
-v
Start editing in vi mode, as if the command name was vi or view.
Command input for ex/vi is read from the standard input. In the vi interface, it is an error if standard input is not a terminal. In the ex interface, if standard input is not a terminal, ex will read commands from it regardless, however, the session will be a batch mode session, exactly as if the -s option had been specified.
Ex/vi exits 0 on success, and greater than 0 if an error occurs.
Search for the string text in the file, and move the cursor to its first character.
The commands to enter new text are:
a
Append new text, after the cursor.
i
Insert new text, before the cursor.
o
Open a new line below the line the cursor is on, and start entering text.
O
Open a new line above the line the cursor is on, and start entering text.
<escape>
Once youve entered input mode using the one of the a, i, O or o commands, use <escape> to quit entering text and return to command mode.
The commands to copy text are:
yy
Copy the line the cursor is on.
p
Append the copied line after the line the cursor is on.
The commands to delete text are:
dd
Delete the line the cursor is on.
x
Delete the character the cursor is on.
The commands to write the file are:
:w<carriage-return>
Write the file back to the file with the name that you originally used as an argument on the vi command line.
":w file_name<carriage-return>"
Write the file back to the file with the name file_name.
The commands to quit editing and exit the editor are:
:q<carriage-return>
Quit editing and leave vi (if youve modified the file, but not saved your changes, vi will refuse to quit).
:q!<carriage-return>
Quit, discarding any modifications that you may have made.
One final caution. Unusual characters can take up more than one column on the screen, and long lines can take up more than a single screen line. The above commands work on physical characters and lines, i.e. they affect the entire line no matter how many screen lines it takes up and the entire character no matter how many screen columns it takes up.
Vi only. Select an alternate word erase algorithm.
"autoindent, ai [off]"
Automatically indent new lines.
"autoprint, ap [off]"
Ex only. Display the current line automatically.
"autowrite, aw [off]"
Write modified files automatically when changing files.
"backup [QQ]"
Backup files before they are overwritten.
"beautify, bf [off]"
Discard control characters.
"cdpath [environment variable CDPATH, or current directory]"
The directory paths used as path prefixes for the cd command.
"cedit [no default]"
Set the character to edit the colon command-line history.
"columns, co [80]"
Set the number of columns in the screen.
"comment [off]"
Vi only. Skip leading comments in shell, C and C++ language files.
"directory, dir [environment variable TMPDIR, or /tmp]"
The directory where temporary files are created.
"edcompatible, ed [off]"
Remember the values of the c and g suffices to the substitute commands, instead of initializing them as unset for each new command.
"errorbells, eb [off]"
Ex only. Announce error messages with a bell.
"exrc, ex [off]"
Read the startup files in the local directory.
"extended [off]"
Regular expressions are extended (i.e. egrep(1)- style) expressions.
"filec [no default]"
Set the character to perform file path completion on the colon command line.
"flash [on]"
Flash the screen instead of beeping the keyboard on error.
"gtagsmode, gt [off]"
Use GTAGS and GRTAGS instead of tags.
"hardtabs, ht [8]"
Set the spacing between hardware tab settings.
"iclower [off]"
Makes all Regular Expressions case-insensitive, as long as an upper-case letter does not appear in the search string.
"ignorecase, ic [off]"
Ignore case differences in regular expressions.
"keytime [6]"
The 10ths of a second ex/vi waits for a subsequent key to complete a key mapping.
"leftright [off]"
Vi only. Do left-right scrolling.
"lines, li [24]"
Vi only. Set the number of lines in the screen.
"lisp [off]"
Vi only. Modify various search commands and options to work with Lisp. "This option is not yet implemented."
"list [off]"
Display lines in an unambiguous fashion.
"lock [on]"
Attempt to get an exclusive lock on any file being edited, read or written.
"magic [on]"
Treat certain characters specially in regular expressions.
"matchtime [7]"
Vi only. The 10ths of a second ex/vi pauses on the matching character when the showmatch option is set.
"mesg [on]"
Permit messages from other users.
"modelines, modeline [off]"
Read the first and last few lines of each file for ex commands. "This option will never be implemented."
"noprint [QQ]"
Characters that are never handled as printable characters.
"number, nu [off]"
Precede each line displayed with its current line number.
"octal [off]"
Display unknown characters as octal numbers, instead of the default hexadecimal.
"open [on]"
Ex only. If this option is not set, the open and visual commands are disallowed.
"optimize, opt [on]"
Vi only. Optimize text throughput to dumb terminals. "This option is not yet implemented."
"paragraphs, para [IPLPPPQPP LIpplpipbp]"
Vi only. Define additional paragraph boundaries for the { and } commands.
"path []"
Define additional directories to search for files being edited.
"print [QQ]"
Characters that are always handled as printable characters.
"prompt [on]"
Ex only. Display a command prompt.
"readonly, ro [off]"
Mark the file and session as read-only.
"recdir [/var/tmp/vi.recover]"
The directory where recovery files are stored.
"redraw, re [off]"
Vi only. Simulate an intelligent terminal on a dumb one. "This option is not yet implemented."
"remap [on]"
Remap keys until resolved.
"report [5]"
Set the number of lines about which the editor reports changes or yanks.
"ruler [off]"
Vi only. Display a row/column ruler on the colon command line.
"scroll, scr [window / 2]"
Set the number of lines scrolled.
"searchincr [off]"
Makes the / and ? commands incremental.
"sections, sect [NHSHH HUnhsh]"
Vi only. Define additional section boundaries for the [[ and ]] commands.
"secure [off]"
Turns off all access to external programs.
"shell, sh [environment variable SHELL, or /bin/sh]"
Select the shell used by the editor.
"shellmeta [~{[*?$Q\]"
Set the meta characters checked to determine if file name expansion is necessary.
"shiftwidth, sw [8]"
Set the autoindent and shift command indentation width.
"showmatch, sm [off]"
Vi only. Note matching { and ( for } and ) characters.
"showmode, smd [off]"
Vi only. Display the current editor mode and a modified flag.
"sidescroll [16]"
Vi only. Set the amount a left-right scroll will shift.
"slowopen, slow [off]"
Delay display updating during text input. "This option is not yet implemented."
"sourceany [off]"
Read startup files not owned by the current user. "This option will never be implemented."
"tabstop, ts [8]"
This option sets tab widths for the editor display.
"taglength, tl [0]"
Set the number of significant characters in tag names.
"tags, tag [tags /var/db/libc.tags /sys/kern/tags]"
Set the list of tags files.
"term, ttytype, tty [environment variable TERM]"
Set the terminal type.
"terse [off]"
This option has historically made editor messages less verbose. It has no effect in this implementation.
"tildeop [off]"
Modify the ~ command to take an associated motion.
"timeout, to [on]"
Time out on keys which may be mapped.
"ttywerase [off]"
Vi only. Select an alternate erase algorithm.
"verbose [off]"
Vi only. Display an error message for every error.
"w300 [no default]"
Vi only. Set the window size if the baud rate is less than 1200 baud.
"w1200 [no default]"
Vi only. Set the window size if the baud rate is equal to 1200 baud.
"w9600 [no default]"
Vi only. Set the window size if the baud rate is greater than 1200 baud.
"warn [on]"
Ex only. This option causes a warning message to the terminal if the file has been modified, since it was last written, before a ! command.
"window, w, wi [environment variable LINES]"
Set the window size for the screen.
"windowname [off]"
Change the icon/window name to the current file name even if it cant be restored on editor exit.
"wraplen, wl [0]"
Vi only. Break lines automatically, the specified number of columns from the left-hand margin. If both the wraplen and wrapmargin edit options are set, the wrapmargin value is used.
"wrapmargin, wm [0]"
Vi only. Break lines automatically, the specified number of columns from the right-hand margin. If both the wraplen and wrapmargin edit options are set, the wrapmargin value is used.
"wrapscan, ws [on]"
Set searches to wrap around the end or beginning of the file.
The number of columns on the screen. This value overrides any system or terminal specific values. If the COLUMNS environment variable is not set when ex/vi runs, or the columns option is explicitly reset by the user, ex/vi enters the value into the environment.
EXINIT
A list of ex startup commands, read if the variable NEXINIT is not set.
HOME
The users home directory, used as the initial directory path for the startup $HOME/.nexrc and $HOME/.exrc files. This value is also used as the default directory for the vicd command.
LINES
The number of rows on the screen. This value overrides any system or terminal specific values. If the LINES environment variable is not set when ex/vi runs, or the lines option is explicitly reset by the user, ex/vi enters the value into the environment.
NEXINIT
A list of ex startup commands.
SHELL
The users shell of choice (see also the shell option).
TERM
The users terminal type. The default is the type unknown. If the TERM environment variable is not set when ex/vi runs, or the term option is explicitly reset by the user, ex/vi enters the value into the environment.
TMPDIR
The location used to stored temporary files (see also the directory edit option).
Vi/ex uses this signal for periodic backups of file modifications and to display busy messages when operations are likely to take a long time.
SIGHUP SIGTERM
If the current buffer has changed since it was last written in its entirety, the editor attempts to save the modified file so it can be later recovered. See the vi/ex Reference manual section entitled Recovery for more information.
SIGINT
When an interrupt occurs, the current operation is halted, and the editor returns to the command level. If interrupted during text input, the text already input is resolved into the file as if the text input had been normally terminated.
SIGWINCH
The screen is resized. See the vi/ex Reference manual section entitled Sizing the Screen for more information.