CLI Usage
7750 SR OS Basic System Configuration Guide Page 45
EX Commands
The vi editor is built upon another editor, called EX. The EX editor only edits by line. From the
vi editor you use the : command to start entering an EX command. This list given here is not
complete, but the commands given are the more commonly used. If more than one line is to be
modified by certain commands (such as
:s and :w ) the range must be specified before the
command. For example, to substitute lines 3 through 15, the command is
:3,15s/from/this/g.
Table 17: EX commands
vi Command Description
:ab string strings Abbreviation. If a word is typed in vi corresponding to string1, the editor
automatically inserts the corresponding words. For example, the
abbreviation
:ab usa United States of America would insert the
words,
United States of America whenever the word usa is typed
in.
:map keys
new_seq
Mapping. This lets you map a key or a sequence of keys to another key or
a sequence of keys.
:q Quit
vi. If there have been changes made, the editor will issue a warning
message.
:q! Quit
vi without saving changes.
:s/pattern/
to_pattern/
options
Substitute. This substitutes the specified pattern with the string in the
to_pattern. Without options, it only substitutes the first occurence of the
pattern. If a 'g' is specified, then all occurences are substituted. For
example, the command
:1,$s/Alcatel/Alcatel-Lucent/g
substitutes all occurences of
Alcatel to Alcatel-Lucent.
:set [all] Sets some customizing options to
vi and EX. The :set all command
gives all the possible options.
:una string Removes the abbreviation previously defined by
:ab.
:unm keys Removes the remove mapping defined by
:map.
:vi filename Starts editing a new file. If changes have not been saved, the editor will
give you a warning.
:w Write out the current file.
:w filename Write the buffer to the filename specified.
:w >> filename Append the contents of the buffer to the filename.
:wq Write the buffer and quit.