Quick Reference

Control Keys

keypad +
Go to the command area. If you are already in command area then execute any typed command and remain in command area (i.e. same effect as hitting carriage return, except that instead of leaving the command area and returning to the text area, you stay in the command area ready to enter another command.)
keypad -
Take next key typed literally. This disables macro expansion and allows you to enter the function and cursor keys as data.

Cursor Movement Keys

Home
Position the cursor at the first character of the first line of the file.
Ctrl-Home
Position the cursor at of the first line of the currently displayed page.
End
Position the cursor at the last character of the last line of the file.
Ctrl-End
Position the cursor at the last line of the currently displayed page.
PgUp
Display previous page. (Back 23 lines)
Ctrl-PgUp
Scroll the screen back 1 line.
PgDn
Display next page. (Forward 23 lines)
Ctrl-PgDn
Scroll the screen forward 1 line.
/\
Move cursor up one line.
Ctrl-/\
Move cursor up 4 lines.
\/
Move cursor down 1 line.
Ctrl-\/
Move cursor down 4 lines.
<--
Move cursor left 1 column.
Ctrl-<--
Move cursor to start of prev word.
-->
Move cursor right 1 column.
Ctrl--->
Move cursor to start of next word.
Keypad 5
Redisplay with cursor line as defined center line.
Ctrl-Tab
Move to end of line.
Shift-Tab
Move to start of line.
Ctrl-b
Begin an automatic indent. (+4 columns).
Ctrl-e
End an automatic indent. (-4 columns).

Character Editing Keys

Backspace
Delete previous character.
Ins
Toggle character insert mode.
Ctrl-Ins
Insert last deleted character from delete buffer before cursor.
Del
Delete character at cursor. Character is saved in delete buffer.
Ctrl-x
Erase all characters on the line.
Ctrl-y
Erase all characters from cursor to end of line.

Function Keys

F1
Toggle newline mode. If entering newline mode then append after current line. If leaving and current line is null then delete it.
Ctrl-F1
Append line delete buffer after current line.
F2
Toggle newline mode. If entering newline mode then insert before current line. If leaving and current line is null then delete it.
Ctrl-F2
Insert line delete buffer after current line.
F3
Delete current line and save in line delete buffer.
F4
Fill tagged lines or until the next blank line if no tags are set. If option justify is on, then justify the filled text.
Ctrl-F4
Center tagged lines or current line if no tags are set. If option justify is on, then justify the filled text.
F5
Split current line at cursor. If character at cursor is a space then delete it.
Ctrl-F5
Split current line at cursor. Character at cursor always saved.
F6
Join line at cursor with next line. If cursor line does not end in a space, append one before the join.
Ctrl-F6
Join line at cursor with next line.
F7
Tag/untag line for tag operation. If F7 is entered twice in rapid succession then a limited block tag is set.
Ctrl-F7
Remove all tags or reset last tags. Its a toggle.
F8
Request tag operation.
Ctrl-F8
Same as F8, however the move or kopy is performed before the current line. Not valid for limited block tags.
F9
Re-execute last typed command.
F10
Re-display last typed command.

Option Control

Alt-a
Toggle option Anchor.
Alt-b
Toggle option Blank.
Alt-d
Toggle option Dual.
Alt-f
Toggle option Fill.
Alt-j
Toggle option Justify.
Alt-l
Toggle option Limit.
Alt-m
Toggle option Meta.
Alt-s
Toggle option Save.
Alt-t
Toggle option Tabs.
Alt-w
Toggle option Wrap.

Margin Control

Shift-F1
Set left margin at cursor position.
Shift-F2
Set right margin at cursor position.
Shift-F3
Move left margin left.
Shift-F4
Move left margin right.
Shift-F5
Move right margin left.
Shift-F6
Move right margin right.
Shift-F7
Move cursor to left margin.
Shift-F8
Move cursor to right margin.

Line Flags

Alt-c
Toggle continuation flag.
Alt-o
Toggle overstrike flag.
Alt-p
Toggle paragraph flag.

Special Characters

hex 00
Null character. Used to terminate lines within the editor. This character can not be saved in your text.
hex 09
Tab character. Expanded on output to the screen as enough spaces to move to the next tab stop. Tab stops are set every 4 columns.
hex 0a
Linefeed character. The carriage return is mapped into this character on input.
hex a3
Macro disable character. Disables any macro expansion for the next key typed.
hex fd
Accept a character from the keyboard.
hex fe
Recall character. Recall last typed command to the command line.
hex ff
Command character. Collect all following characters up until the next newline in a hidden buffer, then execute the buffer as a command.
\
Escape character. Will remove special significance of any meta character it precedes in a pattern. In patterns and the translate command a \hh sequence (hh is two hex digits) will reduce to a single character with hex value hh.
@$^^&.*[-
Meta characters. Only special within patterns when option meta is enabled (m+).

Editor Commands

All editor commands are entered in the command area and executed by typing either the carriage return or the keypad + key. The latter will keep you in the command area while the former will in general return you to the text area. In the following descriptions variable input of a particular class will appear in a special typeface e.g. variable Editor commands are of the form:

[range]C[argument]

where:

range
is a range of lines the command is to operate on.
C
is a single character indicating a command.
argument
is command specific information.

Line Range range

<none>
(none; range not specified) Refers to the current line only.
line
Refers to this line only.
line1,line2
Refers to lines between line1 and line2 inclusive.
line1;line2
Same as "," except that current line is updated by semicolon to line1.
*
Refers to all lines in the buffer.
#
Refers to any tagged lines.

Line Address line

<none>
(none; line not specified) Refers to the current line only.
number
Refers to the absolute line number specified.
.
Refers to the current line.
$
Refers to the last line.
&
Refers to the top line on your screen.
@
Refers to the defined center line.
%
This refers to the current line if you are in the text area and line zero if you are on the command line.
/pattern/
This serves as the line address of the next line which contains an instance of the specified pattern. The search for pattern will begin at the current cursor position and will continue to the end of the buffer. If no match has been found by that time, the search will wrap around to the beginning of the buffer and continue looking for pattern from line one. If no match is found in the entire buffer then an error will be issued.
?pattern?
This serves as the line address of the previous line which which contains an instance of the specified pattern. The search for pattern will begin at the current cursor position and will go backwards through the buffer wrapping around from the first to last line if necessary. If no match is found an error will be issued as above.

In addition, line addresses may be combined with other line addresses using the + and - keys to form expressions. You may limit a line address to lie within the buffer (between 1 and $) by following it with an or-bar (|). For example

.+5|
Refers to the 5th line after the current line or the last line if there are less than five lines after the current line.

Meta Characters Used in Patterns

.
(dot) Matches any character.
^
(caret) Matches the null string at the beginning of the line.
$
Matches the null string at the end of the line.
@(number)
Matches the null string before the numberth character of a line.
@(.)
Matches the null string before the current cursor position.
@(t)
Matches the null string before the next tab stop.
[characters]
Matches any one of the characters enclosed by the square brackets. (character class)
[^characters]
Matches any one character which is not enclosed by the square brackets. (character class)
*
Matches the preceding pattern zero or more times. (closure)
&
Only special in the replacement text of a Substitute command. It will be expanded into the text matched.
-
Only special within the square brackets of a character class above. The syntax character1-character2 is an abbreviation to mean all characters between character1 and character2 inclusive. For example [a-z0-9].

File I/O Commands

e file
Delete current buffer and read in the specified file if the buffer has not been modified.
ee file
Delete current buffer and read in the specified file.
r file
Read the specified file after the current line.
liner file
Read the specified file after the specified line.
w file
Write your buffer to the specified file.
rangew file
Write the line range specified to the specified file.
wa file
Append your buffer to the specified file.
rangewa file
Append the line range specified to the specified file.
x file
Execute the specified file as a file of editor commands. This is typically used for loading custom macro files.

Alphabetical List of All Editor Commands

[line]a
append
[line]a text
append text
[line]ad
append delete buffer
bnumber
branch always number newlines
bnumbert
branch if TRUE number newlines
bnumberf
branch if FALSE number newlines
[range]c
change
[range]c text
change for text
[range]d
delete
e
edit current file
e file
edit file if buffer clean
ee file
edit file
f
query current file
f file
set current file
[range]g/pattern/editor commands
global
[range]g^/pattern/editor commands
global
h number
hold for number time units
[line]i
insert
[line]i text
insert text
[line]id
insert delete buffer
[line]j
join line and line+1
[range]ktarget_line
kopy range after target_line
l character
learn character until Break
[range]mtarget_line
move range after target_line
oC{+|-|~|?}
Set (+), unset (-), toggle (~) or query (?) the option signified by character C. Valid option characters are:
a
option anchor
b
option blank
c
option command
d
option dual
e
option environment
f
option fill
i
option insert
j
option justify
l
option limit
m
option meta
n
option newline
s
option save
t
option tab
w
option wrap
[range]p
print expanding non-printing ascii characters into \hh sequences.
[range]P
print without expanding non-ascii characters.
q
quit the editor if buffer has not been modified
qq
quit the editor regardless
[line]r
read the current file after line
[line]r file
read file after line
[range]s/pattern/replacement_text/
Substitute text; characters other than / may also be used as the delimiter
[range]snumber/pattern/replacement_text/
Substitute text, numberth occurrence only.

Where:

/
is a single character deliminator (Usually a slash, but other characters may be used
number
is the numberth occurrence
t character replacement_text
define translate for character
t character
remove translate for character
t ? character
query translate for character
[range]ucount editor_commands
until count
[range]ucond editor_commands
until cond
[range]uCountCond editor_commands
until Count or Cond, where cond is one of "t" (TRUE) or "f" (FALSE).
vanumber number number
change color of display areas
vc
center display
vc number
set center line
vlquantity
set left margin
vrquantity
set right margin
quantity
scroll display
vw
don't wait for horizontal retrace when using color card
[range]w
write to current file
[range]w file
write to file
[range]wa
write append to current file
[range]wa file
write append to file
x
execute current file
x file
execute file
[range]y"prompt_text"command_chars"commands
yut
[range]zcccharacter
zap cursor change
[range]zcd
zap cursor delete
[range]zce
zap cursor erase
[line]zcfcharacter
zap cursor fill character
[line]zchlocation
zap cursor horizontal
[line]zcl
zap cursor lock
[line]zcp
zap cursor purge character delete buffer
[range]zcr
zap cursor restore from character delete buffer
[range]zcRnumber
zap cursor restore number characters
[range]zcs
zap cursor save in character delete buffer
[line]zkline
zap kopy to/from command line
[range]zlc
zap line center between margins
[range]zld
zap line delete between limits
[range]zle
zap line erase between limits
[range]zlf
zap line fill between margins
[range]zlj
zap line join
[range]zlo
zap line overstrike
[range]zlp
zap line paragraph
zlq
zap line query if tags are set
[line]zlr
zap line restore delete buffer at cursor
[range]zls
zap line save text between limits in delete buffer
[line]zlt
zap line tag
zlu
zap line unset/set all tags
zm
zap message
[line]zp
zap purge line delete buffer
[line]zq
zap query

Examples

Remove leading blanks on all lines:

*s/^ *//

Remove trailing blanks on all lines:

*s/ *$//

Reverse order of all lines:

*m0

Duplicate all lines:

*k$

Duplicate current line:

.k.

Print first 4 lines after each "function":

g/function/.,.+4p

Delete all empty lines:

g/^$/d

Delete all lines which contain only spaces or are empty:

g/^ *$/

Delete all lines containing the word comment:

g/comment/d

Place a "," after each "however":

g/however/s//&,/

Place a line containing the word "end" after each "begin":

g/begin/a end

Turn runs of spaces into tabs:

s/@(t)/\01/s/ *\01/\09/