Structuris Regularis Expressio
Before the reader passes judgment while reading this article. I assure you that the following prose will not be about editor preferences. Instead, we will simply use the choice of one's preferred editor to introduce the wonderful world of structural regular expressions. Let's start with a personal example:
$EDITOR="$(command -v sam 2>/dev/null || command -v ed)"
# we have nvim, not in an SSH term, and the X11 display number is under 10
if command -v nvim >/dev/null 2>&1 \
&& [ "$SSH_TTY$DISPLAY" = "${DISPLAY#*:[1-9][0-9]}" ]; then
export VISUAL="$(command -v nvim) -f"
SUDO_EDITOR="$VISUAL"
else
SUDO_EDITOR="$EDITOR"
fi
When i need hyperfocus, get things done now performance, and distraction is reaching into the crevices of my eyeballs, attempting to steer them towards unfocused land; the sam
editor from p9p is my preferred weapon.
As a former ed
user, i was always enamored with the minimalism and the distraction free environment that it gave. In terms of efficiency & laziness, it achieved high marks in both those areas for me. Why wouldn't it? it was used to write UNIX after all! However, once one becomes conversant in its language, you'll plateau. As the built-in data structure of ed
's language (and most text-processing tools) is the line. And that is precisely where the sam
editor aimed to improve upon.
Rather than bore you with my possible over-simplifications, i shall direct you to the actual whitepaper. Give it an honest read and a solid try, and it may just change the way you edit code or prose.
Until next time.
Happy hacking!
P.S: If sam
catches your fancy and you're a vimmer; you will find green pastures in vis
land.
p9p: https://9fans.github.io/plan9port/
vis editor: https://github.com/martanne/vis
whitepaper: http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf