I've been having fun, playing with regular expressions in vi. But I'd like to do more.

How can I do a search that regards line breaks as if they were a space?

If that's not easy, then how can I replace all line breaks with a space except for line breaks or double line breaks preceding any line that begins with "^"?

I have a text file that has been line wrapped at about 80 characters. Each real line begins with the "^". Each wrapped line does not. And each line that begins with "^" is preceded by a blank line.

Text that I want to search for (or replace) can wrap around these line breaks, but not around the "^".

Example:
^1 This is a line
that is broken by
the super-imposed
word wrapping.

^2 Short line.

^3 Another line.

^4 Yet another.

^5 Some lines:
they wrap; Some
lines: they don't.

If I want to search the file for "line that is" and replace it with "line which is", I would do ":%s/line that is/line which is/cg". But this would totally miss the only occurrence of it in my example above. If I could get vi to regard line breaks (during a search or replace) as if they were a space, I'd be set.


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to