start page | rating of books | rating of authors | reviews | copyrights

Learning the vi Editor

Learning the vi EditorSearch this book
Previous: A. Quick ReferenceAppendix BNext: B.2 Alphabetical List of Commands
 

B. ex Commands

Contents:
Command Syntax
Alphabetical List of Commands

This appendix describes the syntax of ex commands and then presents an alphabetical list of ex commands.

B.1 Command Syntax

To enter an ex command from vi, use this form:

:[address]command[options]

address is the line number or range of lines that are the object of command. If no address is given, the current line is (usually) the object of the command.

B.1.1 Address Symbols

In ex command syntax, address can be specified in any of the forms shown in Table B.1.


Table B.1: ex Address Syntax
AddressIncludes
1,$All lines in the file
x,yLines x through y
x;y

Lines x through y, with current line reset to x

0Top of file
.Current line
nAbsolute line number n
$Last line
%All lines; same as 1,$
x-nn lines before x
x+nn lines after x
-[n]One or n lines previous
+[n]One or n lines ahead
'xLine marked with x
'' Previous mark
/pat/ or ?pat?Ahead or back to line where pat matches

B.1.2 Option Symbols

In ex command syntax, options might be any of the following:

!

Indicates a variant form of the command, overriding the normal behavior.

count

The number of times the command is to be repeated. count cannot precede the command, because a number preceding an ex command is treated as a line address. d3 deletes three lines beginning with the current line; 3d deletes line 3.

file

The name of a file that is affected by the command. % stands for current file; # stands for previous file.


Previous: A. Quick ReferenceLearning the vi EditorNext: B.2 Alphabetical List of Commands
A. Quick ReferenceBook IndexB.2 Alphabetical List of Commands

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System