Loading ...
Sorry, an error occurred while loading the content.

removing linebreaks

Expand Messages
  • Taylor, Kevin
    I need to remove some linebreaks and can t quite get it done with the substitute command. Here is what I have: And I want just
    Message 1 of 2 , Jul 6, 2005
    • 0 Attachment
      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
    • Tim Chase
      ... well, there are multiple ways to do it. While you can do it with a substitute command ... will trim any whitespace (including newlines). See ... for more
      Message 2 of 2 , Jul 6, 2005
      • 0 Attachment
        > 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
      Your message has been successfully submitted and would be delivered to recipients shortly.