From: Tim Chase, Wed, October 18, 2006 12:00 pm
>
> > The application is this :version pretty-fier:
> >
> > function! Str_wrap(str, len)
> >   return substitute(a:str, '[[:print:]]\{,'.a:len.'}','&\n','g')
> > endfunction
>
> I must be missing something...in your original post, you didn't
> have any linebreaks in your sample str...thus my answer didn't
> deal with them. ;)

Flagrant error on my part in not posting a proper test case. :)

> If you have a multi-line string and want to do a wrapping as
> something sorta like "gqip" would do (minus its internal
> smartness about things like comment-leaders or mail-quote
> characters),
>
> echo substitute(@", '\([[:print:]]\{,10}\)\>[^[:cntrl:]]', '&\n', 'g')
>
> seems to do something fairly reasonably kinda sorta close to what I
> understand you to be describing.   :)

I'm still baffled with what is happening to returns when this ends up
in a function:

  function! Str_wrap(str, len)
      return substitute(a:str, '\([[:print:]]\{,' . a:len .
          \ '}\)\>[^[:cntrl:]]', '&\n', 'g')
  endfunction
  function! Version()
      redir @x
      silent! version
      redir END
      echo Str_wrap(@x, 70)
  endfunction
  call Version()

Tony's previous approach is a work-around, but I'm trying to write a
more generic substitution for wrapping.


-- 
Steve Hall  [ digitect dancingpaper com ]

Reply via email to