substituting for multiple newlines in vim

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

substituting for multiple newlines in vim

jkilbour
I am having difficulty using

:% s/\n\n//g

How can I remove multiple (or even single) newlines from a document (I am
on WIndows)

Thanks.


Reply | Threaded
Open this post in threaded view
|

Re: substituting for multiple newlines in vim

Bugzilla from peterp@stack.nl
Op Thursday 08 September 2005 15:17, schreef [hidden email]:
> I am having difficulty using
>
> :% s/\n\n//g
>
> How can I remove multiple (or even single) newlines from a document (I am
> on WIndows)

You could use:
:g/^$/d

which would search for all empty lines (beginning-of-line followed by
end-of-line)


Peter Palm
Reply | Threaded
Open this post in threaded view
|

Re: substituting for multiple newlines in vim

Tim Chase-2
In reply to this post by jkilbour
> I am having difficulty using
>
> :% s/\n\n//g
>
> How can I remove multiple (or even single) newlines from a
> document (I am on WIndows)


You can actually do a search/replace for multiples as you're
doing above.  However, note that if you have a single line
between two lines of text, such as

        foo

        bar

you'll end up with the result as "foobar".

The typical idiom for removing blank lines is either

        :v/./d

or

        :g/^\s*$/d

If, however, you want to condense multiple blank lines into a
single blank line, you can use

        :%s/\n\+/\r\r

Hope one of these provides the behavior you're looking for.

-tim




Reply | Threaded
Open this post in threaded view
|

RE: substituting for multiple newlines in vim

vishnu-3
In reply to this post by jkilbour
Hi jkilbour,

Use the following regular expression,
:%s/\n*//g

~Vishnu

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Thursday, September 08, 2005 6:47 PM
To: [hidden email]
Subject: substituting for multiple newlines in vim

I am having difficulty using

:% s/\n\n//g

How can I remove multiple (or even single) newlines from a document (I
am
on WIndows)

Thanks.


Reply | Threaded
Open this post in threaded view
|

Re: substituting for multiple newlines in vim

jkilbour
In reply to this post by Bugzilla from peterp@stack.nl
Thanks all. I used Peter's suggestion, then copied the document back into
Microsoft Word search-replace to finish the job (adding the newlines where
they should have been).

John

> Op Thursday 08 September 2005 15:17, schreef [hidden email]:
>> I am having difficulty using
>>
>> :% s/\n\n//g
>>
>> How can I remove multiple (or even single) newlines from a document (I
>> am on WIndows)
>
> You could use:
> :g/^$/d
>
> which would search for all empty lines (beginning-of-line followed by
> end-of-line)
>
>
> Peter Palm



Reply | Threaded
Open this post in threaded view
|

post content displays in Korean

jkilbour
Do others have difficulty reading posts to the list that appear in Korean
script, as this one by Daum? I am not sure if there is a setting I should
change, or if the post really is in Korean.



>
>
>  New Document
>
>
>
>
>
> td { font-size:10pt; font-family:????; color:#404040;}
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ????????. ??f?? ???????? ?????? ???? ??? ?????
>       Daum?????????.??????? ??????? ????: d????8??
> ???????? d????8?? ?????? ??????4??.  ????????? ??ô?
> ????? ???? ?????? ????; ??? ?????? ?? ????
> '????¹???  [????]?? [????? ????]????? ????? ??;
> ???????????? ??; ??? ???? ??  ??4??.
>  ?????ð??? [????]?? [????? ????]????? ????? ?????
> ??; ?? ??ø?
>       ?? ?????? ??; ?????? ???4??.
>  ??????? ????? ???? ????? ??? d???? ??; ????
>       ???????? ?????? ????; ?2??8?? ????? ???? ??: ???
Reply | Threaded
Open this post in threaded view
|

Re: post content displays in Korean

Dominic Evans
The daum replies you get are just spam from a webbot that just sends
you back what you sent to the messageboard (with some foreign text
above your post) Its an unfortunate annoyance but its not real
posts/questions so don't worry about reading it - just
ignore/blacklist :)

Cheers,
Dom
 
On 08/09/05, [hidden email] <[hidden email]> wrote:
> Do others have difficulty reading posts to the list that appear in Korean
> script, as this one by Daum? I am not sure if there is a setting I should
> change, or if the post really is in Korean.
Reply | Threaded
Open this post in threaded view
|

Re: post content displays in Korean

A.J.Mechelynck
In reply to this post by jkilbour
----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, September 08, 2005 3:40 PM
Subject: post content displays in Korean


> Do others have difficulty reading posts to the list that appear in Korean
> script, as this one by Daum? I am not sure if there is a setting I should
> change, or if the post really is in Korean.

1. Daum's emails, although they "reply" to list posts, are not posts to the
list: they are sent directly to the author of a list post without going
through the list router at Berlin University.
2. They are really in Korean. Daum Communications, Inc. is a big Korean
corporation which has nothing to do with Vim.
3. I regard them as spam. Please don't spam the list again by sending to it
copies of these emails.
4. I can see the Korean characters in your mail by selecting View ->
Coding -> Korean (ISO) in Outlook Express.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: substituting for multiple newlines in vim

A.J.Mechelynck
In reply to this post by jkilbour
----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Thursday, September 08, 2005 3:17 PM
Subject: substituting for multiple newlines in vim


>I am having difficulty using
>
> :% s/\n\n//g
>
> How can I remove multiple (or even single) newlines from a document (I am
> on WIndows)
>
> Thanks.

    :1,$g/^$/d

Best regards,
Tony.