Home | Onion mirror | Git repo | Git onion | Site map | RSS

Meet Sam

Plan 9’s Sam editor by Rob Pike is a pretty neat editor. For my day-to-day editing of text, Acme is my editor of choice, but for server use, Sam is extremely useful.

Sam has this extremely useful feature where you can run the host part on a remote machine, but run the terminal component locally. Previously I had been using vi on my server, but I have plan9port installed on it anyway, so I figured that switching from Acme to Sam for server editing would be more comfortable than switching from Acme to vi.

The first thing I noticed was how much more responsive Sam was than vi. Sam uses ssh to connect to the remote server, which is what I would do to access vi, but since the terminal is running locally, there is zero lag between pressing a key and it the editor registering it. Basically all the important stuff is done locally, so the only time you’ll see any ssh lag is when you read from or write to the disk.

The only thing that takes some getting used to is the command language. Some of it is familliar to me from my vis days, but some things are sort of strange.

Sam takes an interesting approach to representing files. Instead of merely being a collection of lines, Sam makes use of a very expressive toolbox of commands and regular expressions. This means that whenever you want to run a command on certain elements of a file, you first need to use a regular expression to select certain bits of that file. It works better than vim macros, I think, but it does take some getting used to. Acme can also make use of this, using its Edit command, so knowlege in one applies to the other. Most editing can be comfortably done without having to enter a command though. Like Acme, using it is a very zen experience.