Last Updated: February 25, 2016
· catenate

Use the Acme Edit command to search and replace across many buffers

Acme is a tiling window manager, editor, and shell interface, and is part of Inferno, Plan 9, Plan 9 from User Space (plan9port), Acme SAC, etc.

The Edit program automates buffer editing in Acme. Edit is a separate executable which Acme runs. It talks behind the scenes to all the control files Acme publishes for the files it edits, just like any program you could write yourself. So the editing features are not built into the Acme executable, and are independently changeable. (This outsourcing of even core (to other editors) functionality inverts the emacs approach, which brings everything into a big global elisp space.)

On Hacker News, jff wrote on thread "Plan 9 from Bell Labs (1995)":

It's easy to apply an editor command across every open buffer, if you need to refactor for instance.

As as example:

Edit X/.* / ,s,loginAdmin,loginIdiAmin,g

I edit this text (in a guide file for the current directory) to suit my current need; highlight it by dragging while the left mouse button is down; and then middle-click anywhere on the highlight to run it. After I run it, every open buffer that was changed gets a dirty-bit marker, and I can either middle-click the word Putall (usually in the top row) to save all the files' changes, or Undo (in any buffer's tag) to undo all of the changes across all buffers.

X/.* / says to address every open buffer, since .* matches any pattern. There should not usually be a space after the asterisk, but HN's formatdoc makes the following text italic and removes the asterisk if I don't put a space there. (In Inferno Acme this particular case appears to work anyway, probably because of the space after the filename in buffer tags.)

,-before-s says to edit the entire content of the buffer, not just a highlighted section.

s,loginAdmin,loginIdiAmin, is a tasteless replacement command in Edit's dialect of sam (and in ed, sed, vi, and vim). These commas could be replaced by any character, as long as that character is not in the set of characters to be replaced, or in the replacement set.

g-after-, says to replace every instance of loginAdmin, not just the first.

Say Thanks
Filed Under