Friday, March 6, 2015

Re: Bug: (was vimscripting problem w/tabs and expanding width w/numbering option)

Christian Brabandt wrote:
  That looks strange indeed. I would suggest to postpone the resizing   until Vim has started up completely. Since there are some checks in the   Code that postpone processing, if Vim is starting.  
----
    How do I do that in a gvimrc?
  Also you might want to consider to use the BufWinEnter or WinEnter   autocommand, since I think checking the numberwidth option should be   done, when entering the buffer in a window (by which that setting might   be different than when first loading that buffer).  
---
    That's what I originally had.  but that didn't work and with
the X-window being expanded twice (once for each tab), so I had
a width of '92'.  Original post from a month ago:


-------- Original Message --------
Subject: vimscripting problem w/tabs and expanding width w/numbering option
Date: Sun, 08 Feb 2015 15:59:17 -0800
From: L. A. Walsh
To: Vim Users


Ages ago I add a few lines to my .gvimrc file to auto-resize
the width if I turned on line numbering (i.e. since the numbers take
up more width and I still wanted an 80-col display for the contents),
I wanted to expand the width by the # cols needed.
I added a simple function to my .gvimrc:

func! SetNumberAndWidth()
  set number
  let &columns += &numberwidth
endf
au BufReadPost *   let ln = 1+line("'\"") | if search("vim=:SetNumberAndWidth",'n') | call SetNumberAndWidth() | endif

...content elided...

After tolerating this for several months, I decided to try to take a stab
fixing this, changing my .gvimrc code to handle this:

func! SetNumberAndWidth()
    set number
    if (! exists("g:added_numwth")) | let g:added_numwth=0 | endif
    if (g:added_numwth < &numberwidth)
        let g:added_numwth = &numberwidth
        let &columns = 2 + g:added_numwth + &columns
    endif
endf
au BufReadPost * let ln = line("'\"") | if search("vim=:SetNumberAndWidth",'n') | call SetNumberAndWidth() | endif

-----
Now the 2nd tab (initially not displayed) is 5 [columns] too NARROW!!


   So I'm having problems getting them "synchronized".
...
------------------------------------------------------------------------


So I've tried it a few different ways, including the per-buf that
you suggest, and none of them work -- thus my feeling that it
is likely a design-deficit (bug ;^) )


It seems to me that gvim should likely try to keep the *content*
window (exclusive of line numbering and 'foldcolumns') the same in a
graphical client unless it is manually resized or set.
However, either way, whether it narrows the 'content-width' or not,
it should be the same for manual and ".rc-init" methods that reset
the window width.





No comments: