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

61289Re: the perl x operator ( feature request ? )

Expand Messages
  • Bram Moolenaar
    Aug 30, 2005
      Marc Chantreux wrote:

      > is there a way to multiply a string by a number as the perl x operator
      > do ? i haven't found it on the vim doc ( using vim7).
      >
      > in perl :
      >
      > $x = 'ab' x 4
      > $x == 'abababab'
      >
      > it could be usefull to write something like :
      >
      > :s/.*/\='-'len(submatch(0))/
      >
      > or :
      >
      > let indent = ' ' x &sw
      >
      >
      > in the case that there is no way to do it in vim, this is a feature
      > request ! :)

      You can use the repeat() function. Only in Vim 7 though!

      :let x = repeat('ab', 4)
      :let seperator = repeat('-', 80)

      --
      hundred-and-one symptoms of being an internet addict:
      131. You challenge authority and society by portnuking people

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
    • Show all 6 messages in this topic