Command Overview
Colon (ex) Commands
BVI

[ Cursor Movements | Edit Cmds | Yank and Put Cmds | Set Options | Colon (ex) Cmds ]

When forming a colon command, the first character, the colon, can be followed by zero, one or two addresses. These addresses are byte addresses, in contrast to vi, which uses line addresses.
The byte addresses can be given in decimal notation or, with a leading zero, in hexadecimal notation. If you have specified an address offset (e.g. :set offset=256), this offset has to be added to the byte addresses.
Without an address, the whole file is affected or the current cursor position is used (depending of the command).

AddressCorresponding bytes
.The current byte
7The seventh byte of file (if offset=0)
.-nn bytes before the current byte
.+nn bytes after the current byte
'xThe byte marked with x
^The first byte in file
$The last byte
''The previous current byte
/pat/The first byte that matches pat
#12 A4 6F#The first byte that matches hex pattern
CommandBVIVI
File
Commands
:w
:w %.new
:w filename
:w>> existingfile
:w! file
:e newfile
:e!
:f
:f newname
Write to the current file
Write to current.new
Write to filename
Append to existing file
Overwrite existing file
Terminate session and edit newfile
Reload the current file
Prints current filename and some additional info
Changes the current filename to newname
Substitute
Commands
:s/pattern/replace/
:s/pattern/replace/g
:s/pattern/replace/gc
Search for pattern and replace it once
Search for pattern and replace it global
Search for pattern and replace it global conditional (ask)
:s\80 af\ff ff\ Binary search and replace
Not available
Edit
Commands
:a m
:c m  
:i m
append
change
insert bytes, where m is a(scii), b(inary), d(ecimal), h(exadecimal) or o(ctal). You can type in several (screen) lines of bytes, a line with only a '.' in it terminates the command.
Usually not available in vi but in ex (without the m - modifier).
Logical
Operations
:and n
:or n
:xor n
:neg
:not
:sl
i
:sr i
:rr i
:rl i
and n
or n
exclusive or n
negate
invert
shift left i bits
shift right i bits
rotate left i bits
rotate right i bits
Not available.
Miscellaneous
:g/pat/p
:n
:q
:rew
:sh
:so
file
:ve
:x
:!
command
Global search for pattern pat
Next file to edit
Exit session without saving the file
Rewind to first file
spawn a new shell
Read and execute a file with colon commands
Version of the editor
Exit session, save the file if changed
execute a system command
Currently not available
:map
:unm(ap)
:ab(breviate)
:una(bbreviate)

[ Cursor Movements | Edit Cmds | Yank and Put Cmds | Set Options | Colon (ex) Cmds ]

Back to the topBack to the top


Last update: October 30th 1999 by Gerhard Bürgmann