Saturday, April 9, 2011

Re: Eliminating EOL in text files

Am 16.12.2010 17:21, schrieb Tim Chase:
> On 12/16/2010 10:05 AM, Anthony Campbell wrote:
>> That joins ALL the lines. What I need to do is to have each paragraph as
>> a contimuous line, so that when I import the file into oowriter it will
>> be easily editable.
>
> You might try:
>
> :g/\%^\|\n\@<=\s*\n/,/\n\n\|\%$/j

This one is much simpler!!
:g/\S/,'}j

It also works better at EOF (no additional empty lines needed!)

I'd first make all blank lines empty:
:%s/^\s\+$//e

... because :'} skips blank but non-empty lines.


> It doesn't leave a blank space between each paragraph, but since each
> paragraph is pulled into its own line, you can easily post-process them
> back in:
>
> :%s/$/\r
>
> (that may add an extra at the bottom...a small price of clean-up to pay)

or not:
:%s/\%$\@!$/\r

another version (this adds an empty line at EOF):
:g/^/put _

> -tim

--
Andy

--
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: