On 02/06/2010 8:54 AM, Christian Brabandt wrote:
On Wed, June 2, 2010 1:30 pm, Jürgen Krämer wrote:
The replacement text
\=submatch(1) . repeat(' ',&tw ?&tw :&wm ? winwidth(0) -&wm :
winwidth(0) - len(submatch(1)) - len(submatch(2))) . submatch(2)
Shouldn't that be something like that
\=submatch(1) . repeat(' ', (&tw ?&tw :&wm ? winwidth(0) -&wm :
winwidth(0)) - len(submatch(1)) - len(submatch(2))) . submatch(2)
(note that added paranthesis...)
Also, one should be aware, that len and strlen returns the byte length
of its argument, but one rather would like to have the character width.
That would mean, one needs to do
len(substitute(submatch(1), '.', 'x', 'g')) to return the character width.
I wrapped that into a command:
command! FullJustifyHelpLine
:s/^\s*\(.\{-\}\)\s\+\(\*.*\*\)\s*$/\=submatch(1) . repeat(' ', (&tw ?
&tw : &wm ? winwidth(0) - &wm : winwidth(0)) - len(submatch(1)) -
len(submatch(2))) . submatch(2)/<CR>
So, with your cursor on that line, simply run:
:FullJustifyHelpLine
Can anyone think of a better name :-)
Dave
--
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