Here is my test data
Example 1     Of medium length     Enough words in description
to need one reformat
Example 2     Very short one       Needs no reformat
Example 3     Extremely long one   This description is long
enough and drivels on and on pointlessly for no other purpose
than to trigger multiple reformatted lines.

Here are the :s commands which produced the best results so far and
show exactly what I'm trying to achieve
:'a,'b-1s/.\{66,}/\=substitute(submatch(0),'\(.\{35}\)\(.\{,30}\)
\(\(.\{,30}\)[ \n]\)\+','\1\2\r@@\1\3','')/g
:'a,'b-1s/^@@\(.\{35}\)/\=substitute(submatch(1),'.',' ','g')
Here is what they do to my test data
Example 1     Of medium length     Enough words in description to
                                   need one reformat
Example 2     Very short one       Needs no reformat
Example 3     Extremely long one   This description is long
                                   multiple reformatted lines.

So, it loses the interior lines of a multiple reformat.  To get
those I revisualized the structure of these lines thus:
\(.\{35}\)\(.\{,30}\)\( .\{,30}\)\+
and that all I really needed to do is replace that leading
space in each of the repeated third fields with \r@@\1, ie
that my first :s should be something like
:'a,'b-1s/.\{66,}/\=substitute(submatch(0),'\(.\{35}\)\(.\{,30}\)\(
.\{,30}\)\+', "\=substitute(submatch(3), '^ ', '\r@@\1', '')", 'g')
which produced this output
=substitute(submatch(3), '^ ', '
@@ ', '')
Example 2     Very short one       Needs no reformat
=substitute(submatch(3), '^ ', '
@@ ', '')=substitute(submatch(3), '^ ', '
@@ ', '')
which I read as the second \=expression is not being treated
as such, but no variations like doubling the \ to cater for
the enclosing "s makes any difference. Advice as to how to
proceed, please.



-- 
Graham Lawrence

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to