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

Re: writing a string after every nth character

Expand Messages
  • Brett Pershing Stahlman
    ... From: Jürgen Krämer To: vim mailing list Sent: Monday, December 02, 2002 6:12 AM Subject: Re: writing a string after
    Message 1 of 6 , Dec 2, 2002
    • 0 Attachment
      ----- Original Message -----
      From: Jürgen Krämer <jkraemer@...>
      To: vim mailing list <vim@...>
      Sent: Monday, December 02, 2002 6:12 AM
      Subject: Re: writing a string after every nth character



      Hi,

      Praveen Jalem wrote:
      >
      > i want to write a string 'test' after every 4th character on a line.
      > e.g.
      > '123456789111111' shud be changed to
      > '1234test5678test9111test111'

      :%s/\d\{4\}/&test/g

      Unless I'm mistaken, there should not be a \ before the closing curly brace;
      also, if you may have non-digit characters on a line, you should use .
      instead of \d:

      :%s/.\{4}/&test/g

      Brett S.

      Regards,
      Jürgen

      --
      Jürgen Krämer Softwareentwicklung
      Habel GmbH mailto:jkraemer@...
      Hinteres Öschle 2 Tel: (0 74 61) 93 53 15
      78604 Rietheim-Weilheim Fax: (0 74 61) 93 53 99
    • Jürgen Krämer
      Hi, Brett Pershing Stahlman wrote: [quoting corrected] ... no, it s optional. Regards, Jürgen -- Jürgen Krämer
      Message 2 of 6 , Dec 2, 2002
      • 0 Attachment
        Hi,

        Brett Pershing Stahlman wrote:

        [quoting corrected]

        > ----- Original Message -----
        > From: Jürgen Krämer <jkraemer@...>
        >
        >> :%s/\d\{4\}/&test/g
        >
        > Unless I'm mistaken, there should not be a \ before the closing curly brace;

        no, it's optional.

        Regards,
        Jürgen


        --
        Jürgen Krämer Softwareentwicklung
        Habel GmbH mailto:jkraemer@...
        Hinteres Öschle 2 Tel: (0 74 61) 93 53 15
        78604 Rietheim-Weilheim Fax: (0 74 61) 93 53 99
      Your message has been successfully submitted and would be delivered to recipients shortly.