
\documentclass[12pt]{article}
\usepackage[T2A,OT1]{fontenc}
\usepackage[default]{cantarell}
\usepackage[a4paper, top=20mm, bottom=20mm, left=20mm, right=20mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[russian, english]{babel}
\usepackage{tabu}
\usepackage{hyperref}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[normalem]{ulem}
\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}
\usepackage{setspace}
\onehalfspacing
\author{Artyom Bologov \href{mailto:my-ed@aartaka.me}{(email)}}
\date{\today}
\title{My ed(1) Toolbox}
\makeatletter
\def\endenv{\expandafter\end\expandafter{\@currenvir}}
\makeatother
\begin{document}
\maketitle

\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{./assets/my-ed.png}

Apparently, I’m a huge ed(1) fan.
I keep posting about it and use it as e.g. my Git editor, sudo editing tool,
\href{run:this-post-is-ed}{and my static site generator}.
But am I using it raw and standard as it is?
Sometimes yes, but mostly no.
This post is a listing of all the ed implementations and scripts I use.

\section*{GNU ed + red—Eternal Classics} \label{ed-red}

ed(1) is the standard text editor.
And it’s available on most UNIX/POSIX-derived systems.
(Some Linux distributions don’t provide it in default installation anymore, but that’s on them!)
So relying on ed(1) and its powers is a good bet.

That’s why I always have GNU ed installed on my systems.
It’s battle-tested, intuitive, and easily scriptable.

Bundled with GNU ed (and any POSIX-compliand ed(1) really), red(1) is the “restricted” version of ed(1).
It’s locked to the directory it’s called in.
And has no ability to pass through to the shell.
I find it relatively useless though:
I use ed(1) on secure systems and never allow anyone to access my precious ed(1) session.
But still, red(1) is nice to have!

\section*{oed—OpenBSD ed} \label{oed}

Now, GNU ed is not conforming to POSIX in some behaviors:

\begin{itemize}\item It has more CLI flags
\item It has \verb|wq|
\item It has POSIX extended regular expressions (EREs,) while most other implementations don’t.
  Thus making EREs a non-portable extension
\end{itemize}

I risk introducing non-portable behavior if I only focus on GNU ed.
And I want to have my scripts
\href{run:this-post-is-ed}{(including my website build scripts)}
portable across implementations.

So I installed OpenBSD ed
\href{https://github.com/ibara/oed}{from the repository kindly provided by one of the maintainers}.
And now I can safely replace \verb|ed| with \verb|oed| for most of my scripts.
As the least effort shot at portability.
It’s too convenient to not use it now.

\section*{wed—ed wImproved} \label{wed}

I asked it on GNU ed mailing list whether they might support scripting abilities.
Like sed(1) \verb|-e| and \verb|-f| flags or as a special executable for it.
One of the maintainers (predictably) replied that they (mostly) abide by POSIX and won’t add it.

But! there was a person that emailed me personally and recommended
\href{https://github.com/slewsys/ed}{slewsys ed} as a version of ed(1) supporting scripts (among many other things.)
So I installed it and called it wed(1) just to distinguish this re-implementation from The ed(1).

I don’t really use wed(1)—I’m fine with standard ed(1)
\href{#xed}{(and my scripting wrapper for it)}.
Bust still, it’s a modern and user-friendly extension.
Want to get started with ed(1) but don’t want to deviate from the tradition?—this is the one to start with, probably.

\href{https://futurism.com/married-hologram-glitch}{Don’t get wed to an anime hologram}.
Get wed(1).

\section*{aed—Blaphemy Against Minimalism} \label{aed}

I understand the complaints about ed(1) being somewhat hostile to new users.
It’s usually mitigated by the time spend with this magnificent software.
But still, ed(1) is not perfect and might need some modernization.

\href{https://codeberg.org/aartaka/aed}{So I made aed(1)} as a better and more interactive ed(1).
It’s mostly abusing Readline and shell scripts to deliver a friendlier experience.
With syntax highlighting and perfectly inline-editable inputs.

So once you’re comfortable with basic ed(1).
\href{#wed}{(Or it’s slightly friendlier wed(1) version.)}
You might want to speed up your workflows with aed(1)!

I might’ve gone too far though.

\section*{xed—You Don’t Need sed} \label{xed}

I have a user-friendly ed(1) on me now for interactive use.
One use-case for ed(1) is not covered yet though—scripting!
Having to do this type of newline-delimited scripts is too verbose compared to sed(1) ones.

\begin{figure}[h!]\begin{verbatim}
dirname=$(printf "a
$1
.
g|/|s|.*/
||p
Q\n" | ed -s)
\end{verbatim}\caption{Relatively ugly ed(1) script}\end{figure}

What if I told you this is doable with a one-liner using my xed(1) script?
Here:

\begin{figure}[h!]\begin{verbatim}
xed "a\n$1\n.\ng|/|s|.*/||\np"
\end{verbatim}\caption{xed script}\end{figure}

It’s not the prettiest one, but it’s fulfilling many sed(1) use-cases.
Speaking of the devil...

\section*{sed and ex... No.} \label{sed}

\href{run:sed-ed}{You don’t need sed(1)}.

You don’t need ex(1) either, because it’s too vi(1)-oriented.
They promised ed(1) eXtended, but we got ed(1) Fucked Up.
Commands are incompatible with ed(1).
Configuration is useless in ex(1) mode.
Overall, ex(1) is just a poorly integrated back-end for vi(1).

\section*{My own ed(1) implementations} \label{mine}

If one likes some piece of software as an idea, they will inevitably try to reproduce it.
So I did.
\href{https://github.com/bf-enterprise-solutions/ed.bf}{I implemented ed(1) in Brainfuck} under the aegis of Brainfuck Enterprise Solutions.
\href{https://github.com/aartaka/ed.bas}{I also did one in BASIC}, pushing the limits of the no-memory BASIC as far as possible.
\href{https://github.com/aartaka/ed.modal}{And, finally, I did ed(1) in Modal}, a term-rewriting-only system.
All of these are useable... to a certain extent.
But they don’t compare to the magnificence and purity of the Standard Text Editor.

\section*{Use ed(1)} \label{use}

Whatever implementation you pick (pick aed(1)!), use it and love it.
Because ed(1) deserves your love 😌

\href{https://github.com/Sasquatch-Labs/ed-museum}{See also: ed-museum}.


\par\noindent\rule{\textwidth}{0.4pt}
\href{https://creativecommons.org/licenses/by/4.0}{CC-BY 4.0} 2022-2026 by Artyom Bologov (aartaka,)
\href{https://codeberg.org/aartaka/pages/commit/a91befa}{with one commit remixing Claude-generated code}.
Any and all opinions listed here are my own and not representative of my employers; future, past and present.
\end{document}
