Suppose I have opened a text file in ed, and the current line looks like this:
This is sentence one. Here starts another one.
Now I want to put a newline after one.
, such that the new sentence starting with Here starts
occupies the next line.
How do I do this in ed?
You use the s
command to make substitutions. The format is:
s/pattern/replacement/
To include a newline in the replacement, escape it with a backslash, then press the return key:
s/one. /one.\
/
Where you literally press return, rather than include a \r
or \n
.