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

Re: How can I automatically join lines?

Expand Messages
  • Dan Sharp
    ... I think ... will do what you want. Dan Sharp _________________________________________________________________ Send and receive Hotmail on your mobile
    Message 1 of 3 , Apr 2, 2002
    • 0 Attachment
      >From: darren chamberlain <dlc@...>
      >
      >/=$ matches the pattern; I want to do, basically:
      >
      >:%s/=$/shift j
      >
      >But how do I do the shift-J on the right hand side?

      I think

      :g/=$/normal J

      will do what you want.

      Dan Sharp

      _________________________________________________________________
      Send and receive Hotmail on your mobile device: http://mobile.msn.com
    • Thomas Köhler
      ... You mean something like ... (for each line that ends in = , apply the join command)? Of course, you should decide whether you mean + or = in the
      Message 2 of 3 , Apr 2, 2002
      • 0 Attachment
        darren chamberlain wrote [020402 17:15]:
        > Quick question (hopefully):
        >
        > I just grabbed a file from a mailing list archive which has lines longer
        > than 72 characters terminated with "+" and wrapped to the next line.
        > The file is 600 lines long, and most of the lines have these
        > continuations. How can I quickly join the lines?
        >
        > /=$ matches the pattern; I want to do, basically:
        >
        > :%s/=$/shift j
        >
        > But how do I do the shift-J on the right hand side?

        You mean something like
        :g/=$/j

        (for each line that ends in "=", apply the "join" command)?

        Of course, you should decide whether you mean "+" or "=" in the
        first place :-)

        Now, when you have several lines ending in "+" (I go for that one
        for the moment), you might need
        :g/+$/.,/[^+]$/j

        (So, whenever you find a line that ends in a "+", start a range
        from that line (".") to the next end that doesn't end in "+" and
        join that range completely.

        Of course, this doesn't get rid of the "+" itself...
        If you want that, you might want to give
        :%s/+\n//
        a try...

        Ciao,
        Thomas

        --
        Thomas Köhler Email: jean-luc@... | LCARS - Linux
        <>< WWW: http://jeanluc-picard.de | for Computers
        IRC: jeanluc | on All Real
        PGP public key available from Homepage! | Starships
      Your message has been successfully submitted and would be delivered to recipients shortly.