Colon (ex) Commands

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
:w filename
:w>> existingfile
:w! file
:e newfile
:f newname
Write to the current file
Write to
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
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
:a m
:c m 
:i m
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).
:and n
:or n
:xor n
:sr i
:rr i
:rl i
and n
or n
exclusive or n
shift left i bits
shift right i bits
rotate left i bits
rotate right i bits
Not available.
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

Back to the top
Page updated: September 9th 2013 by Gerhard Bürgmann, Purkersdorf/Austria
Have a look at "Lighting Lifts"