How to delete empty lines in multi-ranges in Vim
Posted
by Kev
on Stack Overflow
See other posts from Stack Overflow
or by Kev
Published on 2010-06-16T09:21:11Z
Indexed on
2010/06/16
10:22 UTC
Read the original article
Hit count: 187
I get a text file:
<p>...</p>
<pre>
...
...
...
...
</pre>
<p>...</p>
<p>...</p>
<p>...</p>
<pre>
...
...
...
</pre>
<p>...</p>
Notice that: there are some empty lines between [pre]...[/pre].
I want to delete them.
But, I want keep those in [ p]...[/p]
The text file becomes:
<p>...</p>
<pre>
...
...
...
...
</pre>
<p>...</p>
<p>...</p>
<p>...</p>
<pre>
...
...
...
</pre>
<p>...</p>
I use the cmd below to located them:
/<pre>\n\zs\_.\{-}\ze\n<\/pre>
But I don't know what to do next!
I need a one-line-cmd to do this.
Any idea? Thanks!
The simpler, the better!
Edit: Thank you all. I just figure out how to do it with the help of my another question
:g/<pre>/,/<\/pre>/s/^$\n//
© Stack Overflow or respective owner