sam
Editor ReferenceThis is a blatent rip-off of Steve Simon’s reference card.
n,m
Line n
to line m
’
Address mark, see k below
.
Correct selection/position
0
Correct 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
d
Delete text in dot
s/regexp/text/
Substitute text for regexp in dot
m address
Move dot to after address
t address
Copy dot to after address
p
Print contents of dot
=
Print value of dot
n
Print file menu list
b file-list
Set current file to first in menu list
B file-list
Same as b, but load new file-list
D file-list
Delete named buffers
e [file-name]
Replace current with file
r file-name
Replace dot by contents of file
w file-name
Write current to named file
f [file-name]
Set current file name
< command
Replace dot by stdout of command
> command
Send dot to stdin of command
| command
Pipe dot through command
! command
Run the command
x/regexp/ command
Set dot and run command on each match
x cmd
Set dot and run command on each matching line
y/regexp/ command
As x but select unmatched text
X/regexp/ command
Run command on files whose menu line matches
Y/regexp/ command
As X but select unmatched files
g/regexp/ command
If dot contains regexp, run command
v/regexp/ command
If dot does not contain, run command
k
Set address mark to value of dot
q
Quit
u n
Undo last n
(default 1) changes
{ }
Braces group commands
<compose> Xnnnn
Insert char xxxx
hex (Unix/Plan9)
Alt-nnnn
Insert char xxxx
hex (Windows)
X/.*/,x/<cr>/d
Strip
x/ˆ/ .,/0d
Strip 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 -l
Count lines in file
/text/+-p
Highlight the lines containing <pat>
-/text/
Search for text backwards
$-/text/
Search for the last occurrence of text in file
,x/<text>/+-p
Grep for text
.x/<pat>/ c/<rep>/
Search for <pat>
and replace with <rep>
B < echo *.c
Add all the C files in current dir to file list
B < grep -l <pat> *
Add all the files containing <pat>
to file list
X/’/w
Write all modified files
Y/.c/D
Remove all non C files from file list
| fmt
Pipe selection through the text formatter
> mail <user>
Send selection as Email to <user>
x/0 a/0
Double space selection
x/ˆ/ a/ /
Indent selection 1 tab
x/ˆ<tab>/d
Remove 1 tab of indent from selection
/(.+0+/
Matches blocks of text separated by blank lines
! date
Get current date in sam window
,< wc
Push file into wc, count appears in sam window
0 < date
Insert date at start of file
1 < date
Replace first line with todays date
X D
Remove out all up-to-date files
,|
Sort sort current file
,x/ˆTODAY$/ < date
Replace TODAY on with the output of date
-/.PP/,/.PP/-
Highlight current paragraph in an nroff doc