The Ed Editor by Ken Thompson (Complete Series)

FIRST VIDEO ON ED

An editor developed by Bill Joy in 1976.
It was based on a program called em,
which in turn was an improvement of ed
itself developed by Ken Thompson,
one of the authors of Unix.
Ex is a simple but useful text editor
which itself later became the basis of Vi
which is not to be confused with Vim.
Original Vi was written in 1976
Vim, was only a much later development,
released first in 1991.
But back to ex which is the focus of this video.
ex is a very simple editor helpful for
configuring system files.
Its strange style arose from limitations
imposed by computing at the time.
This is how it works.

  • starting up ex
  • Lines are not automatically shown at startup
  • set line numbers
  • navigation: beginning/end of file 0/$
  • Go to a specific line
  • to copy or move
  • to append text
  • to save and quit
  • find /word
  • to substitute
  • the origin of grep g/re/p
  • to globally substitute g/word/s//newword/g
  • regex expressions, examples:
    whole words \<word\>
    empty lines ^$
    letters and numbers [0-9a-z]
    not [a-zA-Z0-9 ]
  • changing to Vi mode but does things Vi cannot do
  • Write
  • Quit

SECOND VIDEO ON ED (ADVANCED)

Very few/no customizations required
Execute a shell command, or filter lines through a shell commands:
[range]! argument(s)
Add a comment: "
Join lines: :[range] j
Previous file: :prev
Next file: :n
Read the contents of another file after line in current file: 1r [filename]
Show current version of ex: :ve
Write a range of lines to another file – 1,4 w >> [filename]
Go from ex to vi :vi
Go from vi to ex: Q
Shift lines: >> <<
Show the last line: =
Change directory: chdir/cd
Edit a different file: :e
Help for any ex command: :exu[sage]
Display and optionally change the file name: f [newname]
Append after line X: :a
Insert before line X: :i
Create mark: :ma[x]
Goto mark '[x]
Make an excrc file: :mkexrc (This writes abbrevs, editor options
and maps to specific file)
Create abbreviations: :ab teh the
Preserve current state of the file and later recover with ex -r::pre

  • To remove double spaces: g/ *// /g

It was based on a program called EM,
which in turn was an improvement of ED
one of the original authors of Unix.
Ex is a simple but useful tEXt editor
which is not to be confused with VIM.
also by Bill Joy.
VIM was only a much later development,
But back to EX which is the focus of this video.
EX is a very simple editor helpful for
configuring system files.
Ex is provided by default on Windows, Linux and BSD.
It is the default editor in OpenBSD.
This is how it works.

  • starting up EX
  • Ex does some amazing things
  • set line numbers - .exrc
  • to copy(co), move(m), change(c)
  • undo a change (u)
  • to append text: a
  • to save and quit: w q
  • find a word /word g/word
  • to substitute s/word/ newword/g

whole words \<word\>
empty lines ^$
letters and numbers [0-9a-z]
not [a-zA-Z0-9 ]
Replace spaces at the beg. of a line: g/^ */s///
Typing vi at the prompt changes to Vi Mode.
But there are some things Ex does better than Vi.

  • Write

Replace trailing whitespace: g/ *$///
Delete all blank lines: g/^$/d (d = delete)
proantidisestablishmentarianism

Return to Home