Tuesday, July 17, 2012

Re: How to remove empty lines except of one

Here's a pared down version illustrating the problem:

| :%s-\(\%^\|.*\S\+.*\n\)\zs\(^\s*\n\)\{2,\}-\r

Before:

-------------------------------------------------------------------------
1 |
2 |
3 |asdf
4 |
5 |
-------------------------------------------------------------------------

After:

------------------------------------------------------------------------
1 |
2 |asdf
3 |
4 |
------------------------------------------------------------------------

Even though the regex matches, the substitute command fails to collapse
the two empty lines at the end of the buffer.

ibid. Ben Fritz' more efficient approach:

| :%s-^\_s\+\n-\r

Any thoughts..?

CJ

--
Mooo Canada!!!!

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: