ed(1) is the right tool (VIII)
====================================

If you are reading this phlog, it means that you had the patience and
determination to go through the quite bumpy ride of learning the basics
of ed(1). You did well, but I won't congratulate you, though.

Indeed, by learning the basics of ed(1) you have not achieved anything
special: for almost two decades, learning ed(1) was the very first thing
any newbie willing to seriously play with unix had to do. You learned
ed(1) first, and then you could mess around with source code and start
writing your own programs. Then, glassy terminals made the minimalist
terseness of ed(1) unnecessary, and more powerful full-screen visual
editors made their appearance in unix systems, such as emacs and vi
(yes, vi(1), not vim(1). vim(1) came much later).

At that point, ed(1) started being forgotten, since newcomers to the
unix world did not need it for their cool projects, and this little
useful tool acquired the (unjustified) fame of being hard to use and
hard to learn.

I hope this series of posts has shown you that ed(1) is a potentially
very useful tool, which is not that hard to use or to learn. It is
obviously a tool from another era of computing, when minimalism was a
necessity and terseness was a virtue. But its influence on the unix
ecosystem is indeed deep and wide, and by learning its basics we have
had the opportunity to see how the spirit of ed(1) still survives in
hundreds of tools that have inherited its syntax, its commands, its
idioms, its idiosyncrasies.

We have not had the opportunity to talk about all the commands available
in ed(1), but at this point RTFM (i.e., reading the famous man-page)
should be enough for you to get along. I provide here some pointers to
useful stuff:

  - we haven't talked about regular expressions, which make ed(1) so
    much more powerful. Go learn them. I will write a post or two about
    the basics, but in the meanwhile, go learn them.

  - 'k' is for labelling rows, which makes life easier sometimes

  - 'G' is like 'g', but for interactively editing lines

  - 'v' is like 'g', but works on lines NOT matching a pattern

  - 'V' is for... (read the two previous points and use your brain)

  - 'h' prints an explanation of the last error

  - 'H' toggles explation of errors

  - in some implementations, 'z' provides a print-by-screen function

  - in some implementations, 'y' allows to transform a set of characters
    into another, more or less as tr(1) would do, but in some other
    implementations it 'yanks' lines in a temporary buffer

  - in some implementations, 'x' allows to encrypt a buffer before
    writing it to disk, but in other implementations it is used to
    'paste' lines previously 'yanked' with 'y'.
   

I would also encourage you to have a look at the following books and
articles about ed(1):

  - Ed Mastery, by Michael W. Lucas (possibly the best book on ed(1)
    currently available)
    https://mwl.io/nonfiction/tools#ed

  - ed(1) man page in the Single Unix Specification
    https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html

  - ed(1) man page from UNIXv1, ca. 1971
    http://man.cat-v.org/unix-1st/1/ed

  - ed(1) man page from UNIXv7, 1979
    http://man.cat-v.org/unix_7th/1/ed

  - ed(1) at gopherpedia
    gopher://gopherpedia.com/0/Ed (text editor)

  - A history of UNIX before Berkeley, Ian Darwin & Geoffrey Collyer,
    section 3.1
    http://www.darwinsys.com/history/hist.html
  
  - ed(1) is Turing-complete 
    https://nixwindows.wordpress.com/2018/03/13/ed1-is-turing-complete/

  - ed(1) is the standard text editor
    https://www.gnu.org/fun/jokes/ed-msg.txt

That's all, folks! :)

 -+-+-+-