Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

User Commands (v - z) vi(1)
Defining Macros
If you use a subcommand or sequence of subcommands frequently, you can create a macro that
issues the subcommand or sequence when you call a macro. To create a macro, enter the
sequence of subcommands into an editing buffer named with a letter of the alphabet. When used
as buffer names, lowercase ASCII letters a through z overlay the contents of the buffer, while
uppercase ASCII letters A through Z append text to the previous contents of the buffer, allowing
the building of a macro piece by piece.
To invoke the macro, enter @x, where x is the letter name of the buffer. Enter @@ to repeat the
last macro you invoked.
Mapping Keys
You can use the map command to set a keystroke to a subcommand or a sequence of subcom-
mands for use during visual mode. To set a key mapping, enter :map key subcommand where
key is the key to which you want to assign a subcommand or sequence of subcommands and sub-
command is the subcommand or sequence of subcommands. For example, to set X to delete lines,
enter:
:map X dd
In this example, X is the key to which the subcommand is assigned and dd is the subcommand.
In the next example, a subcommand sequence is mapped to a key:
:map * {>}
The * (asterisk) is the key to which the subcommand sequence is assigned and {>} is the subcom-
mand sequence. The { (open brace) moves the cursor to the beginning of the paragraph and the >
(right angle bracket) indents the paragraph to the next shiftwidth.
To display the list of the current key mappings while you are in Command mode, enter the :map
key command. To remove a key mapping, enter :unmap key or :unmap! key where key is the
string used after the :map command to set the key and subcommand sequence. For example, to
remove key mapping for the previous example, enter:
:unmap *
If function keys are defined for your terminal, they can be put in a map or unmap command by
typing <Ctrl-v> and then pressing the desired key. In this way, function keys that are unused
during editing can be mapped to useful editing subcommand sequences.
If the ! (exclamation point) character is appended to the command name map (map!), the map-
ping is effective during input mode rather than during visual mode.
Abbreviations
You can define abbreviations for long phrases that you use often. vi then automatically expands
these abbreviations whenever you enter them in insert mode.
To define an abbreviation, enter:
:abbr abbreviation phrase
where abbreviation is the abbreviation you specify for the longer text specified by phrase.For
example, to specify the abbreviation imho for the phrase In my humble opinion,enter:
:abbr imho In my humble opinion
527188-021 Hewlett-Packard Company 107