Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ex(1) — OSF/1 X2.0-8 MIPS

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ctags(1)

ed(1)

/red(1)

edit(1)

grep(1)

/egrep(1)

/fgrep(1)

vi(1)

/vedit(1)

/view(1)

terminfo(4)

ex(1)  —  Commands

OSF

NAME

ex − Edits lines in a file interactively, with screen display

SYNOPSIS

ex [-lRv] [-wnumber] [+subcommand] [-] [file ...]

ex [-lRv] [-t tag] [file ...]

ex -r[file] [-lRv] [file]

The ex command is a line-oriented text editor that is a subset of the vi screen editor. 

FLAGS

-lIndents appropriately for LISP code, and accepts the (, ), {, }, [, and ] characters (parentheses, braces, and brackets) as text rather than interpreting them as vi subcommands.  The LISP modifier is active in open or visual modes. 

-r[file]Recovers file after an editor or system crash.  If you do not specify file, a list of all saved files is displayed. 

-RSets the readonly option, preventing you from altering the file. 

-ttagLoads the file that contains tag and positions the editor at tag.  To use this flag, you must first create a database of function names and locations using the ctags command. 

-vInvokes the visual editor.  When the -v flag is specified, an enlarged set of subcommands are available, including screen editing and cursor movement features.  See vi. 

-wnumber
Sets the default window size to number lines. 

-Suppresses all interactive user feedback.  If you use this flag, file input/output errors do not generate an error message. 

+subcommand
Begins the edit with the specified editor search or subcommand.  When subcommand is not entered, a + (plus sign) sets the current line to the bottom of the file.  Normally ex sets the current line to the last line of the file, or to some specified tag or pattern. 

DESCRIPTION

The ex editor is similar to ed, but is more powerful, providing multiline displays and access to a screen editing mode.  You may prefer to call vi directly to have environment variables set for screen editing.  Also edit, a limited subset of ex, is available for novices or casual use. 

The file argument specifies the file or files to be edited.  If you supply more than one file, the ex editor edits each file in the specified order. 

To determine how your tty can perform more efficiently, ex uses the tty capability database terminfo and the type of tty you are using from the TERM environment variable. 

The ex editor has the following features:

       •You can view text in files.  The z subcommand lets you access windows of text, and you can scroll through text by pressing <Ctrl-d> and <Ctrl-u> (visual (-v) mode only). 

       •The undo subcommand allows you to reverse the last subcommand, even if it is an undo subcommand.  Thus, you can switch back and forth between the latest change in the edit file and the last prior file status and view the effect of a subcommand without that effect being permanent.  Commands that affect the external environment cannot be undone, however.  The ex command displays changed lines and indicates when more than a few lines are affected by a subcommand.  The undo subcommand causes all marks to be lost on lines changed and then restored if the marked lines were changed.  It does not clear the buffer modified condition. 

       •You can retrieve your work (except changes that were in the buffer) if the system or the editor crashes by reentering the editor with the -r flag and the filename. 

       •You can edit a sequence or group of files.  You can use the next subcommand to edit each file on the command line in turn, or to specify a list of filenames to edit (using the shell pattern matching syntax).  The wildcard character % (percent sign) represents the name of the current edit file and can be used to form filenames. 

       •You can copy and move text within a file and between files (see the co, d, ya, and pu subcommands).  You use a group of buffers (that have the names of the ASCII letter a to z) to move text.  You can temporarily place text in these buffers and copy or reinsert it in a file, or you can carry it over to another file.  The buffers are cleared when you quit the editor.  The editor does not notify you if text is placed in a buffer and not used before exiting the editor. 

       •You can use patterns that match words.  A pattern can be a fixed character string or a regular expression.  A regular expression is a string constructed of special pattern-matching characters.  Using a regular expression to locate text in a file gives you more flexibility than trying to locate a fixed character string.  For more information about regular expressions, see grep. 

Editing Modes

Command mode
When you start the ex editor, it is in command mode.  Enter ex subcommands at the : (colon) prompt.  Pressing <Esc> cancels a partial subcommand. 

Text entry mode
Entered by a, i, and c.  In this state, you can enter text.  Entry state ends normally with a line that has only a . (period) on it or ends abruptly if you press the Interrupt key sequence. 

Visual and open mode
Entered by vi, vi., vi-, or o.  Each of the first three commands gives you a full screen vi editor, but puts the current line in a different place on entry.  Enter vi to put the current line at the top of the screen; enter vi. to put the current line in the middle of the screen; and enter vi- to put the current line at the bottom of the screen.  The o command opens a one-line window.  All three commands share the input state of the vi editor.  Press <Esc> to exit text entry mode.  To return to the ex command state at the current line, enter Q while in command mode. 

ex Limits

The ex editor has the following maximum limits:

       •2048 bytes per line

       •256 bytes per global command list

       •128 bytes in the previous inserted and deleted text

       •128 bytes in a shell escape command

       •128 bytes in a string-valued option

       •30 bytes in a tag name

       •128 map macros with 2048 bytes total

SUBCOMMANDS

The ex subcommands affect the current line unless you specify otherwise.  For information about how to address lines in a file, see edit and vi. 

ex Subcommands

ababbreviate

aappend

arargs

cchange

cd or chdirchange directory

cocopy

ddelete

eedit

exex

ffile

g or vglobal

iinsert

jjoin

kmark

llist

mapmap

mamark

mmove

nnext

nunumber

oopen

prepreserve

pprint

puput

qquit

reread

recrecover

rewrewind

seset

shshell

sosource

ssubstitute

tcopy

tatag

unaunabbreviate

uundo

unmunmap

vglobal

veversion

vivisual

wwrite

xexit

yayank

zwindow

=display addressed line number

#display addressed lines with line numbers

start comment

!escape

<left shift

<Return>display next line

&repeat last substitute subcommand

>right shift

<Ctrl-d>scroll

ex Subcommand Addresses

$The last line

+The next line

−The previous line

+nThe nth line forward

−nThe nth previous line

%The first through last lines

numberLine number

.The current line

x-numberThe numberth line before line x

x,yLines x through y

´mThe line marked with m

´´The previous context

/pattern$The next line with pattern at end of line

/^patternThe next line with pattern at start of line

/patternThe next line with pattern

?patternThe previous line with pattern

Scanning Pattern Formation

^The beginning of the line

$The end of the line

.Any character

\<The beginning of the word

\>The end of the word

[string]Any character in string

[^string]Any character not in string

[x-y]Any character between x and y, inclusive

∗Any number of the preceding character

~The replacement part of the last substitute command. 

/(pattern\)A regular expression pattern can be enclosed in escaped parentheses to identify them for substitution actions. 

FILES

/usr/lbin/exrecoverrecover subcommand. 

/usr/lbin/expreservepreserve subcommand. 

/usr/share/lib/terminfo/?/∗
Terminal information database.

./.exrc or $HOME/.exrcEditor start-up file. 

/tmp/ExnnnnnEditor temporary file. 

/tmp/RxnnnnnNames buffer temporary file. 

/var/preservePreservation directory. 

RELATED INFORMATION

Commands:  ctags(1), ed(1)/red(1), edit(1), grep(1)/egrep(1)/fgrep(1), vi(1)/vedit(1)/view(1). 

Files:  terminfo(4). 

The TERM environment variable. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026