I'm having a mental block, how can I wrap a string via substitute() ?
I've been trying something like:

  let str = "123456789012345678901234567890"
  let str = substitute(str, '\n\([[:print:]]\{-10,}\)', '\n\1\n', '')
  echo str

to produce:

  1234567890
  1234567890
  1234567890

The following seems to do the trick for me:

echo substitute(str, '[[:print:]]\{,10}', '&\n', 'g')

which should also gracefully handle

"123456789012345678901234567890123"

(with the extra trailing 123 at the end, making it a non-even multiple of 10)

-tim


Reply via email to