Acme editor notes

tags: plan9

Resources

Mouse

Acme needs a 3-button mouse to work properly. All buttons can be used to select text, but their function is different upon release. The left button is used for just selecting text. The middle button is used for executing text. The right button is for searching text and loading files or directories. Text doesn’t have to first be selected when using button 2 and 3 (middle and right) if the selection is only one word.

Acme also makes use of mouse chording (e.g pressing more than one button).

Button 1-2 Cut.
Button 1-3 Paste.
Select text + Button 2-1 Execute with selection as argument.

Move around

:2 Go to 2nd line.
:0 Go to beginning of file.
:$ Go to end of file.
CTRL-A Go to beginning of line.
CTRL-E Go to end of line.
CTRL-F Filepath autocompletion.
Edit = Find current line number.

Search and select

:,
Edit ,
Select all lines.
:1,5
Edit 1,5
Select lines 1 to 5.
:/regexp/ Select lines matching regexp.
:/regexp1/,/regexp2/ Select lines between regexp1 and regexp2.
Edit +/foo
:/foo
:foo
Right click on word.
Forward search.
Edit -/foo
:-/foo
:-foo
Backward search.

Edit text

CTRL-U Delete from cursor to beginning of line.
CTRL-W Delete before cursor.
CTRL-H Delete character before cursor.
Edit , d Clear window.
Edit , s/foo/bar/g
Edit , | sed 's/foo/bar/g'
Global replace.
Edit s/foo/bar/g Replace in selection.
Edit 2 d Delete 2nd line.
Edit 2 c/foo Change 2nd line.
Edit 2 a/foo Append after 2nd line.
Edit 2 i/foo Insert before 2nd line.

Work with external commands

cmd Run cmd with the file as argument.
|cmd Pipe selection through cmd and also apply changes.
>cmd Send selection to cmd and see result in a temporary window.
<cmd Paste output of cmd in current window (no selection required).

Any command can be used, these are just a few examples.

Edit , < echo foo Replace window body with some text (works with any command).
echo foo | 9p write acme/$winid/body Append to end of current window body.
Edit , > wc -l Count lines.
Edit , | sort Sort lines.
Edit ,x/regexp/ < date Replace regexp with the output of date(1).
Select text + | sed '' > foo.txt Cut to foo.txt.
Select text + > sed '' > foo.txt Copy to foo.txt.

Files

As mentioned earlier, files are opened using the right mouse click.

foo.c Open file.
foo.c:3 Open file to line 3.
foo.c:3:9 Open file to line 3 column 9.
foo.c:/^func Open file to the line starting with "func".
foo.c:/bar/,/baz/ Open file with a selection from "bar" to "baz".

Useful Acme commands

win Spawn shell as a window.
web URL Open URL in browser.
Dump Save current state.
Load Load dump.
Tab 8 Set tab width to 8.

Variables

$%
$samfile
Current file name.
$winid Current window.