💾 Archived View for idiomdrottning.org › line-moving-semantics captured on 2023-01-29 at 04:31:00. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
In ed, the line editor that the original Unix was written in, you move lines by entering the source and destination numbers with an m in between, like this:
10m5
That will move the line that was the tenth line to now be after the old fifth line and before the old sixth line—it becomes the new sixth
line. (If you are familiar with ed‘s and sed‘s general semantics, one way to express it is that m uses a semantics rather than i semantics.)
In mpc, a command line client for the music player daemon, you move lines by entering the source and destination numbers after an mv command, like this:
mpc mv 10 5
That will move the line that was the tenth line to become the new fifth line. Much more intuitive as far as I’m concerned! I’m not proposing we change ed, it’s a classic, but this is just a heads up for anyone who uses either or both of those programs.
I’m really happy to use mpc, though! Kudos to whomever implemented it! Pro tip, pipe mpc list‘s output through nl to get some line numbers.