[BusyBox] Sed and vi.

Rob Landley rob at landley.net
Fri Oct 10 22:25:34 UTC 2003

On Friday 10 October 2003 04:27, Glenn McGrath wrote:
> On Fri, 10 Oct 2003 00:05:15 -0500
> Rob Landley <rob at landley.net> wrote:
> > You can enter sed commands at the colon prompt of vi.  For example,
> > colon command to global search and replace in the file is
> > "1,$s/old/new/g".
> >
> > Not that i have a shortage of to-do items, but might it be a good idea
> > someday to merge busybox vi and busybox sed somewhat, to cut down on
> > duplication and add functionality?
> I think they might be ed commands, which is about the same as sed.
> There is a feature request for an ed applet, but im not brave enough.
> http://bugs.busybox.net/db/12/1269.html

Ed was the original unix editor back when 64k was as big as PDP-11 RAM got and 
all I/O was done via teletype machines that printed their output on rolls of 
paper.  (I have in fact used such a system, but I was 7 years old at the time 
and it was in my uncle's spare room.)

Ed worked on a file held in memory (a "buffer"), which meant that the file 
sizes it could work on back then were highly constrained because the OS and 
ed executable also had to load into that 64k.  And due to the teletype I/O, 
full screen view of anything just wasn't possible: you typed a command line 
to modify the contents of the buffer.  Append a line of text, insert a line 
of text, change this to this, etc.

Sed was originally created to be a version of ed that worked on larger files 
than could be held in memory, by only reading one line at a time into the 
buffer, applying the command(s) to it, and writing it back out.

vi started life as a visual version of ed, back on early CRT displays that 
didn't have control, alt, or cursor keys as standard yet.  So it had three 
modes: colon brought up an ed style command line, a second mode let you move 
around with the hjkl in place of the yet-to-be-invented cursor keys, and the 
third mode inserted what you typed at the cursor position.  (You toggled 
between the second and third modes with the escape key, although back then it 
was called "meta".)

(Don't get a computer historian started. :)

P.S.  The bell labs guys went on to do their own visual version of ed, called 
sam, a few years after AT&T started trying to commercialize Unix development 
and nobody was paying attention to what the Bell Labs guys were doing 


More information about the busybox mailing list