| Previous | Table of Contents | Next |
COMMANDS
The following table lists all valid ex commands, their abbreviated form, and a brief description.
|
|
||
| Command | Abbr. | Description |
|---|---|---|
|
|
||
| abbrev | ab | Used to define abbreviation strings. |
| append | a | Enter insert mode after current line. |
| args | ar | List args supplied on ex/vi command line. |
| change | c | Change the specified lines. |
| copy | co | Copy the specified lines. |
| delete | d | Delete the specified lines. |
| edit | e | Edit the specified file. |
| file | f | Display status of current file/buffer. |
| global | g | Address entire buffer. |
| insert | i | Enter insert mode. |
| join | j | Join the next line to the current line. |
| list | l | List all characters in raw format. Shows control characters. |
| map | Map a character to perform ex/vi commands. If followed by a ! | |
| (map!) then use as create a substitute string used during insert mode. | ||
| mark | ma | Mark current line for later reference. |
| move | m | Move to specified line. |
| next | n | Edit the next file on the command line. |
| number | nu | Number each line when displayed. |
| preserve | pre | Preserve a copy of the current buffer. |
| p | Print (display) lines of text. | |
| put | pu | Put text in buffer from a register. |
| quit | q | Quit the editor without saving changes. |
| read | re | Read in text from a file or UNIX command. |
| recover | rec | Recover a lost (preserved) file. |
| rewind | rew | Rewind to the beginning of the files on the command line. |
| set | se | Set an ex option. |
| shell | sh | Escape to a UNIX shell. |
| source | sop | Read in and interpret a .exrc type file. |
| stop | st | Suspend (Stop) the editor. (Job Control Systems only) |
| substitute | s | Substitute an old string with a new string. |
| unabbrev | una | Remove an abbreviation string. |
| undo | u | Undo the last command. |
| unmap | unm | Unmap the specified map command. |
| version | ve | Display the version ex/vi you are using. |
| visual | vi | Enter into visual mode, vi. |
| write | w | Write the current buffer to a disk file. |
| xit | x | Exit the editor and save any changes to disk. |
| yank | ya | Yank specified lines to a register. |
| window | z | Set window to the specified size. |
| escape | ! | Escape to UNIX to execute a command. |
| lshift | < | Shift text one shiftwidth to the left. |
| print next | Return | Display the next line of text. |
| resubst | & | Repeat the last substitute command. |
| rshift | > | Shift text one shiftwidth to the right. |
| scroll | Ctrl-D | Scroll the screen down one page. |
|
|
||
Command Format
The ex commands have a general format of
address command count flags
where address, count, and flags are optional. The address is a range or line as described in the Address section. If no address is specified, the current line is usually the default. The command is one of the commands listed in the previous table. The count specifies how many lines are affected by the command. If you specify 3d4, the current line is set to line 3 and 4 lines are deleted. The flags can be one of the following commands.
| l | List the lines, displaying control characters with visual characters. |
| nu # |
Display the lines preceded by line numbers. |
| p | Display (print) the lines. |
| +n | Set the current line forward n lines. |
| -n | Set the current line backward n lines. |
Displaying Text
The following commands may be used to display the contents of the current session buffer you are editing.
| range p count | Print (display) lines specified by range or perform p count times from specified line. | |
| range nu count flags | Print (display) lines specified by range, preceded by line numbers. Flags may be used to perform added functions. For example, | |
| :%nu l | ||
| displays all lines preceded by the line number, with control characters displayed. | ||
| range l count flags | List lines specified by range, showing nonprintable characters. | |
| Ctrl-D | Scroll the next window of text onto the screen. | |
| .= | Display the current line number. | |
Window Sizing
The ex editor displays a window of text if requested. The z command is used to manipulate this window.
| line z type count | Changes current line to line and displays a window consisting of count lines. The type specifies where the current line is displayed in the window. If no type is specified, then the line is placed at the top of the window. If type is a . then the line is placed in the middle and if it is a - the line is placed at the bottom of the window. | |
| Examples: | ||
| :z | Redraw, place the current line at the top of the window. | |
| :z . | Redraw, place the current line at the middle of the window. | |
| :z - | Redraw, place the current line at the bottom of the window. | |
| :/pat/z. | Redraw, place the line with pat at the middle of the window. | |
| :z n | Redraw, use n line window. | |
Inserting Text
The ex editor inserts text one line at a time. You can enter insert mode and enter text until you type a . and press Return at the beginning of a line. If you have the wrapmargin option set, you do not have to press Return at the end of each physical line when entering text.
| line i | Insert text at line line. The insert command places text before the line of text currently at address a. | |
| Example: | ||
| :5i | ||
| This is a new line of text. | ||
| . | ||
| Your new line of text becomes line 5 and the existing line 5 becomes line 6. | ||
| line a | Append text at line line. The append command places the text after the line of text currently at address line. | |
| Example: | ||
| :5a | ||
| This is a new line of text. | ||
| . | ||
| Your new line of text becomes line 6 and the existing line 6 becomes line 7. | ||
Changing Text
The following command is used to change existing lines of text.
| range c count | Enters insert mode and replaces the lines specified by range or count with the new text you typed. If you do not type any new text, the old text is deleted. | |
| Example: | ||
| :7,9 c | ||
| These are new lines of text. | ||
| Inserted as line 7 thru 10. | ||
| Because we added an extra line. | ||
| This replaces lines 7,9 with the three new lines of text. | ||
Copying Text
The following command is used to copy existing lines of text to a new location or duplicate them.
| range co line | Copies the lines specified by range to the line after line. A line of 0 (zero) copies text to the beginning of the buffer. | |
| Example: | ||
| :5,21 co 73 | ||
| Copies lines 5 through 21 and inserts them after line 73. | ||
Deleting Text
The following command is used to delete lines of text.
| range d reg count | ||
| Delete the lines specified by range or count to the named register reg. The originals lines are deleted. Valid register names are a through z. If no register name is provided, the text is placed in the undo register. To retrieve text from registers use the put command. If you use capital letters for register names, the text is appended to the register. | ||
| Example: | ||
| :11,19 d a | ||
| deletes lines 11 through 19 to register a. | ||
| :32 d 8 | ||
| deletes lines 32 through 40 (deletes the 8 lines following line 32). | ||
Marking Positions
The mark command allows you to create specific addresses. Thus you can create blocks of text based on these addresses. The one drawback to marks is that they are invisible. You mark a position in the buffer but you cannot see the mark.
| line ma x | Mark line number line as address or position x. | |
| Example: | ||
| :ma a | ||
| marks the current line as position a. | ||
| 'x | Reference address or position a. Once you have a position marked you can use the position as an address for other commands. | |
| Example: | ||
| :'a,'a+5 co 1 | ||
| copies the lines from position a through position a+5 to line 1. | ||
Moving Text
The following command is used to move existing lines of text to a new location.
| range m line | Moves the lines specified by range to the line after line. A line of 0 (zero) moves text to the beginning of the buffer. | |
| Example: | ||
| :5,21 m 73 | ||
| moves lines 5 through 21 to after line 73. | ||
| Previous | Table of Contents | Next |