How to replace in vim a newline by a space? - Editors
This is a discussion on How to replace in vim a newline by a space? - Editors ; Hello,
how, i. e. with which command, can all newlines of a textfile be replaced by
spaces with vim 6.1?
Thanks for all good hints.
Thomas Wiedmann...
-
How to replace in vim a newline by a space?
Hello,
how, i. e. with which command, can all newlines of a textfile be replaced by
spaces with vim 6.1?
Thanks for all good hints.
Thomas Wiedmann
-
Re: How to replace in vim a newline by a space?
On Jun 17, 3:43 am, "Thomas Wiedmann" <t...@gmx.de> wrote:
> Hello,
>
> how, i. e. with which command, can all newlines of a textfile be replaced by
> spaces with vim 6.1?
>
> Thanks for all good hints.
>
> Thomas Wiedmann
Don't know 6.1 but in 7 it's:
%s/\n/ /cg
if you remove the 'c' it will just change them all without asking you
to 'confirm' each one
http://applications.linux.com/articl...d=13&pagenum=1
rd
-
Re: How to replace in vim a newline by a space?
And to replace spaces with newlines you use:
:%s/ /\r/g
Mark
-
Re: How to replace in vim a newline by a space?
Sun, 17 Jun 2007 10:43:13 +0200 from Thomas Wiedmann <th.wm@gmx.de>:
> how, i. e. with which command, can all newlines of a textfile be replaced by
> spaces with vim 6.1?
Replacing a newline with a space amounts to joining the lines.
I believe :.,$J will do it.
There's a mode setting to determine whether joined lines have a space
between them. If you try the command and you don't get spaces, hit u,
check the help for that mode and set it the other way. :-)
--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
-
Re: How to replace in vim a newline by a space?
On Jun 17, 2:03 pm, "znxs...@gmail.com" <znxs...@gmail.com> wrote:
> And to replace spaces with newlines you use:
>
> :%s/ /\r/g
Why is newline \r and not \n in the replacement part of a vim regex?
When matching it is \n and that's the "normal" designation. I've been
wondering about that for ages.
Tom
-
Re: How to replace in vim a newline by a space?
On 2007-06-18 03:08:46 -0500, bakert <bakert@gmail.com> said:
> Why is newline \r and not \n in the replacement part of a vim regex?
> When matching it is \n and that's the "normal" designation. I've been
> wondering about that for ages.
I think that this is the way that nedit does it, too.
--
Aaron Hsu <aaron.hsu@sacrificumdeo.net>
"No one could make a greater mistake than he who did nothing because he
could do only a little." - Edmund Burke
-
Re: How to replace in vim a newline by a space?
On 18 Jun, 09:08, bakert <bak...@gmail.com> wrote:
> Why is newline \r and not \n in the replacement part of a vim regex?
> When matching it is \n and that's the "normal" designation. I've been
> wondering about that for ages.
>
> Tom
I am not an authority on this but my understanding is that when you
press the Enter key, that is in fact a carriage return (\r). However
once inserted you get a line break (\n). Why this is done that way I
am unaware.
Hope that helps explain in some way why \r is used.
Thanks
Mark
Similar Threads
-
By Application Development in forum C
Replies: 0
Last Post: 11-12-2007, 08:15 PM
-
By Application Development in forum cobol
Replies: 20
Last Post: 11-02-2007, 04:15 AM
-
By Application Development in forum CSharp
Replies: 10
Last Post: 10-17-2007, 03:02 PM
-
By Application Development in forum TCL
Replies: 2
Last Post: 08-23-2007, 11:34 AM
-
By Application Development in forum Javascript
Replies: 5
Last Post: 07-03-2007, 03:02 PM