Hi,
Visco Shaun wrote:
>
> On Thu, 2009-04-16 at 17:50 +0530, Visco Shaun wrote:
>> Hi
>>
>> Is there any way to adjust automatically the window size so that we have
>> a fixed no of char-width(say 80) even though the number of digits of
>> lineno(by 'set no') shown on left changes.
>>
>> At present I am using command 'winsize 83 51' assuming the maximum
>> lineno to be a 3 digit no.
>>
>
> So does that mean there is no way out if this prob(as nobody yet
> replied)?
you might try something like the following
function! ActualNumberWidth()
if !&number
return 0
endif
let numwidth = strlen(line('$')) + 1
return (numwidth > &numberwidth) ? numwidth : &numberwidth
endfunction
au CursorHold,CursorHoldI * let c=80 + ActualNumberWidth() | if c != &columns
| let &columns=c | endif
The function calculates the space used for the last line number if the
'number' option is set, and the autocommand sets the new width if
the size has changed. You can remove the test for changes, but then you
will notice a flickering whenever the CursorHold/CursorHoldI event is
fired
Expanding the function to multiple windows with different number widths
is left as an exercise to the reader. ;-)
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---