ex commands

2009 Mar 01


Address Includes
1,$
%
all lines in the file
0 top of file
. current line
$ last line
n line n
x,y lines x through y
-[n] one or n lines previous
+[n] one or n lines ahead
'x lines marked with x
x-[n] one or n lines before x
x+[n] one or n lines after x
' ' previous mark
/pat/ ahead to match of pat
?pat? back to match of pat
ex commands are of the form
   :[address]command[options]
Option Meaning
! A variant form of command (override)
count repeat command count times
file Filename:
   % is current file,
   # is previous file

For map command #n
represents function key n

To enter characters such as Esc, ^[,
or CR, (^M), first type ^V.
Command Meaning
ab [string text] Abbreviate
(be careful
of recursion)
[address]a[!]
text
.
Append
ar Args
[address]c[!]
text
.
Change
[address]co destination Copy
[address]d [buffer] Delete
e[!][+n [filename] Edit
[address]g[!]/pattern/[commands] Global
[address]i[!]
text
.
Insert
[address]j[!][count] Join
[address]k char marK
[address]l[count] List
map[!] [char commands] Map
! input mode
[address]m destination Move
n[!] [[+command] filelist] Next
[address]nu [count] Number
[address]o [/pattern/] Open
Command Meaning
pre Preserve
[address]p [count]
[address]P [count]
Print
[address]pu [char] Put
q[!] Quit
[address]r filename
[address]r !command
Read
rec filename Recover
rew[!] Rewind
set
set option
set nooption
set option=value
set option?
Set
so Shell
sh filename Source
[adrs]s [/pat/repl/][opts] Substitute
[address]t destination To
[address]ta tag Tag
una word Unabbreviate
u Undo
unm char Unmap
[address]v/pattern/[commands] V (global exclude)
ve Version
Command Meaning
[address]vi [type][count]
vi [+n][filename]
Visual
[address]w[!] [[>>]filename]
[address]w ![command]
Write
wq[!] Write & Quit
x eXit
[address]y [char][count] Yank
[address]z [type][count]
type can be one of
+place line at top of window
.place line at center of window
-place line at bottom of window
^print previous window
=place line at center of window
and leave current line at this line
Z (position line)
[address]!command !
[address]= = (line number)
[address]<
[address]>
<> (shift)
address] Address
RET Return (next line)
[address]& [options][count] Repeat substitute
[address]! [options][count] Repeat substitute
but with last regexpr

2005-2009