removing linebreaks

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

removing linebreaks

Taylor, Kevin
I need to remove some linebreaks and can't quite get it done with the
substitute command. Here is what I have:
      <property
         name="receiptDate"
/>

And I want just want it delete the line break:
      <property
         name="receiptDate "/>

Any help would be appreciated. TIA!

Kevin Taylor
Sr Web Developer


Reply | Threaded
Open this post in threaded view
|

Re: removing linebreaks

Tim Chase-2
> I need to remove some linebreaks and can't quite get it done
> with the substitute command. Here is what I have:
>       <property
>          name="receiptDate"
> />
>
> And I want just want it delete the line break:
>       <property
>          name="receiptDate "/>

well, there are multiple ways to do it.

While you can do it with a substitute command

        :%s/\(name="receiptDate"\)\_s*/\1

will trim any whitespace (including newlines).  See

        :help /\_

for more on that.

Alternatively, you can use the Join command. In Normal mode, you
can simply use "J" to join the current line with the next one. If
you want to preserve the whitespace, you can use "gJ".

You can also do the same sort of thing from an Ex command.

        :help J
        :he gJ
        :he :j

This is handy for use within a global command, such as your
previous example...

:g/name=/j

will join every line containing "name=" with the following line.

All sorts of options :)

-tim