Ex Quick Reference

Entering/leaving EX

% ex nameedit name, start at end
%ex +n name... starting at line n
% ex -t tagstart at tag
%ex -rlist saved files
%ex -r namerecover file name
%ex name name ...edit first; rest via :n
%ex -R nameread-onlymode
:xexit, saving changes
:q!exit, discaring changes (quit)

Ex states

CommandNormal and inital state. Input prompted for by :. Your kill character cancels partial command.
InsertEntered by a, i and c. Arbitary text then terminates with line having only . character on it or abnormally with interrupt.
Open/visualEntered by open or vi, terminates with Q or ^\.

Ex cammands

abbrevab
appenda
argsar
changec
copyco
deleted
edite
filef
globalg
inserti
joinj
listl
map
markma
movem
nextn
numbernu
openo
preservepre
printp
putpu
quitq
readre
recoverrec
rewindrew
setse
sourceso
stopst
substitutes
unabbrevuna
undou
unmapunm
versionve
visualvi
writew
xitx
yankya
windowz
escape!
lshift<
print next<CR>
resubst&
rshift>
scroll^D

Ex Command Addresses

n line n
. current
$ last
+ next
- n forward
+n n forward
/pat next with pat
?pat last with pat
x-n n before x
x,yx through y
'x marked with x
'' previous context

Specifying Terminal Type

%setenv TERM type csh and all version 6
$ TERM=type;export TERM version 7

See also rset(1)

Some Terminal Types

Initialisation Options

EXINITplace set's here in environment var.
set x enable option
set noxdisable option
set x=valgive value val
setshow changed options
set x?show value of option x

Useful Options

   
autoindentaisupply indent
autowriteawwrite before changing files
ignorecaseicin scanning
lisp() {} are s-exp's
listprint ^I for tab, $ at end
magic.|* special in patterns
numbernu number lines
paragraphsparamacro names which start
redraw simulate smart terminal
scroll command mode lines
sectionssectmacro names...
shiftwidthswfor < >, and input ^D
showmagicsmto ) and } as typed
slowopenslowchoke updates during insert
window visual mode lines
wrapscanwsaround end of buffer?
wrapmarginwmautomatic line splitting

Scanning Pattern Formation

^beginning of line
$end of line
.any character
\<beginning of word
\>end of word
[str]any char in str
[^str]any char not in str
[x-y]any char betwene x and y
*any number of preceding

VI Quick Reference

Entering/Leaving VI

vi nameedit name at top
vi +n name... at line n
vi + name... at end
vi -rlist saved files
vi -r namerecover name
vi name name ...edit first; rest via :n
vi -t tagstart at tag
vi +/pat namesearch for pat
view nameread-only
ZZexit from vi, saving changes
^Zstop vi for later resumption (suspend - use fg)

The display

Last lineerror messages, echoing input to : / ?
@ linesOn screen only, not in file
~ lineslines past end of input
^xcontrol characters, ^? Is delete
tabsexpand to spaces, cursor at last

VI States

CommandNormal and initial state. Others return here. ESC (escape) cancels partial command
InsertEntered by a I A I o O c C s S R. Arbitary text then terminates with interrupt.
Last lineReading input for : / ? or !; terminate with ESC of CR to execute, interrupt to cancel.

Counts Before VI Commands

z G I
line/column number
scroll amount^D ^U
replicate inserta I A I
repeat effectmost rest

Simple Commands

dwdelete a word
de... leaving punctuation
dddelete a line
3dddel 3 lines
itextESCinsert text text
cwnewESCchange word to new
easESCpluralise word
xptranspose characters

Interrupting/Cancelling

ESCend insert or incomplete command
^?(delete or rubout) interrupts
^Lreprint screen if ^? scrambles it

File Manipulation

:wwrite back changes
:wqwrite and quit
:qquit
:q!quit discard changes
:e nameedit file name
:e!reedit, discard changes
:e + nameedit name from end
:e +nedit from line n
:e #edit alternate file
^[synonym for :e #
:w namewrite file name
:w! nameoverwrite file name
:shrun shell, then return
:!cmdrun cmd, then return
:nedit net file in args
:n argsspecify new arg list
:fshow current file and line
^Gsynonym for :f
:ta tagto tag file entry tag
^]:ta, following word is tag

Positioning within a file

^Fforward screenfull
^Bbackward screenfull
^Dscroll down half screen
^Uscroll up half screen
Ggoto line (end default)
/patnext line matching pat
?patlast line matching pat
nrepeat last / or ?
Nreverse last / or ?
/pat+nnth line after pat
?pat?-nnth line before pat
]]next section/function
[[previous section/function
%find matching () { or }

Adjusting the Screen

^Lclear and redraw
^Rretype, eliminate @ lines
zCRredraw, current at top
z-... at bottom
z.at center
/pat/z-pat line at bottom
zn.use n line window
^Escroll window down one line
^Yscroll window up one line

Marking and Returning

``previous context
''... at first non-white in line
mxmark position with letter x
`xto mark x
'x... at first non-white line

Line positioning

Hhome window line
Llast window line
Mmiddle window line
+next line, at first non-white
-previous line, at first non-white
CRreturn, same as +
down arrow or jnext line, same column
up arrow or kprevious line, same column

Character Positioning

up arrow
0
$
l or right arrowforwards
h or left arrowbackwards
^Hsame as back arrow
spacesame as right arrow
fxfind x forwards
Fx... backwards
txupto x forward
Tx... backwards
;repeat last f F t T
,inservse of ;
|to specified column
%find matching ( { ) or }

Words, sentences, paragraphs

wword forward
b... backweard
eend of word
)next sentence
}next paragraph
(last sentence
{last paragraph
Wblank delimited word
Bback W
Eend of W

Commands for LISP

)Forward s-expression
}... but don't stop at atoms
(Back s-expression
{... but don't stop at atoms

Corrections during insert

^Herase last character
^Werase last word
erasesame as ^H
killerase input this line
\escapes ^H, your erase, kill
ESCends insertion, back to command
^?interrupt, terminate insert
^Dbacktab over autoindent
^Vquote non-printing character

Inser and replace

aappend after cursor
iinsert before
Aapend at end of line
Iinsert before first non-blank
oopen line below
Oopen above
rxreplace single char with x
Rreplace characters

Operators (double to affect lines)

ddelete
cchange
<left shift
>right shift
!filter through command
=indent for LISP
yyank lines to buffer

Miscellaneous Operations

Cchange rest of line
Ddelete rest of line
ssubstitute chars
Ssubstitute lines
Jjoin lines
xdelete chars
X... before cursor
Yyank lines

Yank and put

pput back lines
Pput before
"xpput from buffer x
"xyyank to buffer x
"xddelete to buffer x

Undo, redo, retrieve

uundo last change
Urestore current line
.repeat last change
"dpretrieve dth last delete