> So I want the following text:
> -----------------------------
> Blablabla blablabla blablabla
> blablabla blablabla blablabla blablabla
>
> Blablabla blablabla blablabla. And blablabla.
>
> Xyzxyz xyzxyz
> xyzxyz xyzxyz xyzxyz xyzxyz
>
> xyzxyz xyzxyz xyzxyz. Abcabc abcabc.....
> -----------------------------
>
>
> Most be changed into removing the white line in the "xyz section":
> So
> -----------------------------
> Blablabla blablabla blablabla
> blablabla blablabla blablabla blablabla
>
> Blablabla blablabla blablabla. And blablabla.
>
> Xyzxyz xyzxyz
> xyzxyz xyzxyz xyzxyz xyzxyz
> xyzxyz xyzxyz xyzxyz. Abcabc abcabc.....
> -----------------------------
>
> How to do that?
:%s/\n\_s\+\ze\l/\r
should do the trick. That looks for a newline ("\n") followed by
any amount of whitespace including more newlines ("\_s\+")
followed by a lowercase letter ("\l") and replaces all the
whitespace with a single newline ("\r"). If a line begins with
whitespace followed by a lowercase letter such as
Asdfg asdfg
asdfg asdfg
it will be normalized to strip off the leading whitespace:
Asdfg asdfg
asdfg asdfg
If you don't like that behavior, you can tweak the expression:
:%s/\n\%(\s*\n\)\+\ze\l/\r
which will only swallow blank lines. Lines containing only
whitespace are considered blank in this version. If you don't
like that, you can just use
:%s/\n\{2,}\ze\l/\r
which will only eat repeated newlines, treating lines with only
whitespace as "content-ful" lines.
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---