Thanks guys works like a charms. I am using Christian's version. I prefer the second name: JustifyHelpHeader
2010/6/2 Christian Brabandt <[email protected]> > On Wed, June 2, 2010 3:46 pm, David Fishburn wrote: > > 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> > > > > I have a different suggestion, if I may ;) > :s/^\s*\(.\{-\}\)\s\+\(\*.*\*\)\s*$/\=printf("%s%*.s%s", submatch(1), > ((&tw?&tw:&wm?winwidth(0)-&wm:winwidth(0)) - > len(split(submatch(1).submatch(2),'\zs'))), ' ', submatch(2))/ > > This should be a little bit shorter and should work with multibyte glyphs > as well. > > > So, with your cursor on that line, simply run: > > :FullJustifyHelpLine > > > > Can anyone think of a better name :-) > > JustifyHelpHeader > > regards, > Christian > > -- > 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 > -- Un saludo Best Regards Pablo Giménez -- 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
