Fastest way to delete a sentence in ed

62 views Asked by At

By a sentence in a text I mean a string that may span several lines; its beginning is the beginning of a line, or a period (.) followed by a space, and it is ended by a period followed by at least one space or newline.

What is a good way in ed to delete a sentence, which may span several lines?

1

There are 1 answers

0
Gumnos On BEST ANSWER

When editing prose in ed, I prefer to keep one sentence per line to simplify this. That said, if your sentences flow over multiple lines, it's usually a three-step process to delete them: delete the head of the sentence, delete the tail of the sentence, and the lines in between. Thus you might do something like (using the opening paragraph from Fahrenheit 451 as an example)

10s/With his symbolic helmet.*
11,12d
11s/.*and black.

optionally issuing

10,11j

to join the following text to the previous text.

If you keep one sentence per line, it's as simple as 10d to delete the line in question. This also has the benefits that version control diffs give more helpful output, showing added/removed sentences.