sam Editor ReferenceThis is a blatent rip-off of Steve Simon’s reference card.
n,mLine n to line m
’Address mark, see k below
.Correct selection/position
0Correct selection/position
ˆStart of file
$End of line/file
,Equivalent to 0,$
.Any character
*0 or more of previous
+1 or more of previous
[ˆn]Correct selection/position
[nm]n or m
(re)Tag pattern
#Substitute #’th tagged pattern
-/re/Search backward
+/re/Search forward
/re/Search in same direction as last
a/text/Append text after dot
c/text/Change text in dot
i/text/Insert text before dot
dDelete text in dot
s/regexp/text/Substitute text for regexp in dot
m addressMove dot to after address
t addressCopy dot to after address
pPrint contents of dot
=Print value of dot
nPrint file menu list
b file-listSet current file to first in menu list
B file-listSame as b, but load new file-list
D file-listDelete named buffers
e [file-name]Replace current with file
r file-nameReplace dot by contents of file
w file-nameWrite current to named file
f [file-name]Set current file name
< commandReplace dot by stdout of command
> commandSend dot to stdin of command
| commandPipe dot through command
! commandRun the command
x/regexp/ commandSet dot and run command on each match
x cmdSet dot and run command on each matching line
y/regexp/ commandAs x but select unmatched text
X/regexp/ commandRun command on files whose menu line matches
Y/regexp/ commandAs X but select unmatched files
g/regexp/ commandIf dot contains regexp, run command
v/regexp/ commandIf dot does not contain, run command
kSet address mark to value of dot
qQuit
u nUndo last n (default 1) changes
{ }Braces group commands
<compose> XnnnnInsert char xxxx hex (Unix/Plan9)
Alt-nnnnInsert char xxxx hex (Windows)
X/.*/,x/<cr>/dStrip
x/ˆ/ .,/0dStrip C comments from selection
Goto the 10th colum in the current line
-0+,+0-Round dot down to whole lines only
,x/ +/ v/ˆ/ c/ /Compress runs of spaces, leaving indentation
s/"([ˆ"]*)"/‘‘1’’/Replace “hello” with ‘‘hello’’ in selection
f <nl>Set current file-name to null
> echo ""Insert ascii code xxx at current position
, > wc -lCount lines in file
/text/+-pHighlight the lines containing <pat>
-/text/Search for text backwards
$-/text/Search for the last occurrence of text in file
,x/<text>/+-pGrep for text
.x/<pat>/ c/<rep>/Search for <pat> and replace with <rep>
B < echo *.cAdd all the C files in current dir to file list
B < grep -l <pat> *Add all the files containing <pat> to file list
X/’/wWrite all modified files
Y/.c/DRemove all non C files from file list
| fmtPipe selection through the text formatter
> mail <user>Send selection as Email to <user>
x/0 a/0Double space selection
x/ˆ/ a/ /Indent selection 1 tab
x/ˆ<tab>/dRemove 1 tab of indent from selection
/(.+0+/Matches blocks of text separated by blank lines
! dateGet current date in sam window
,< wcPush file into wc, count appears in sam window
0 < dateInsert date at start of file
1 < dateReplace first line with todays date
X DRemove out all up-to-date files
,|Sort sort current file
,x/ˆTODAY$/ < dateReplace TODAY on with the output of date
-/.PP/,/.PP/-Highlight current paragraph in an nroff doc