winwidth & winheight doesn't work here

185 views
Skip to first unread message

Roger

unread,
Oct 9, 2011, 5:08:32 AM10/9/11
to vim...@googlegroups.com
Reading the good book Learning the VIM Editor(s) and see winwidth & winheight
mentioned, but am having trouble getting it working here!

Why, when settings winwidth on vertical split files, it's not automagically
resizing the windows as I toggle between the files?

I have set to noequalalways, also. :-/

Tony Mechelynck

unread,
Oct 9, 2011, 5:37:56 PM10/9/11
to vim...@googlegroups.com, Roger
On 09/10/11 11:08, Roger wrote:
> Reading the good book Learning the VIM Editor(s) and see winwidth& winheight

> mentioned, but am having trouble getting it working here!
>
> Why, when settings winwidth on vertical split files, it's not automagically
> resizing the windows as I toggle between the files?
>
> I have set to noequalalways, also. :-/
>

With me it does, but remember that these options are "desired minimums
for the current window" and that the "absolute minimums for any window"
are set by 'winminwidth' and 'winminheight'. When switching windows, the
new window will not be resized if it already exceeds the desired
minimum, nor will it be made bigger than would allow all other windows
to remain at or above the absolute minimum.

Also, some special window types have their own desired minimums: see
:help 'helpheight'
:help 'cmdwinheight'
:help 'previewheight'

The absolute minimums may be set to zero, the desired minimum for the
current window must be at least 1 since the currentcursor location must
always be visible.

The following should swell the current window to maximum size, squashing
other windows to only a vertical divider on left and right or a status
line above and below:

:set nowfh " no fixed size
:set noea eadirection=both " no equal size
:set wmw=0 wmh=0 " squash other windows
:set wiw=9999 wh=999 hh=999 cwh=999 pvh=999 " enlarge current window
:let netrw_winsize = 100 " netrw split to 100% size

Best regards,
Tony.
--
"What is wanted is not the will to believe, but the will to find out,
which is the exact opposite."
-- Bertrand Russell, "Skeptical_Essays", 1928

Roger

unread,
Oct 9, 2011, 9:59:06 PM10/9/11
to vim...@googlegroups.com

Great. Thanks Tony. I'll relook over those later settings here. So far,
minheigh/width is set to 0 or 1 here.

--
Roger
http://rogerx.freeshell.org/

Roger

unread,
Oct 15, 2011, 7:59:55 AM10/15/11
to Tony Mechelynck, vim...@googlegroups.com
> On Sun, Oct 09, 2011 at 11:37:56PM +0200, Tony Mechelynck wrote:

For GVIM:
Variable nowfh was already default here.
Variable ea was default, but I set to noea.
Variable eadirection=both was default too.
And set wmw? wmh? were set to default 1.


Now the culprit was your wiw, wh, hh, cwh, pvh values!

My default values were set to something like these:
winwidth=1
winheight=1
helpheight=20
cmdwinheight=7
previewheight=12

And, once I used your wiw, wh, hh, cwh, pvh values, changing focus of the
windowns and window resizing automagically happens now!

(I omitted the 'let netrw_winsize ...' statement as I currently don't want to
resize 100% which would make it look like I have no windows in the buffer.
Guess one could get the status line to display a letter stating there's open
windows, etc... user preference, etc...)

The O'Reilly Learning VIM mentioned something about these values, but gave no
real set values for a reader to try on his/her own VIM session. With your
values, I'm now rolling on customizing to my liking! I never knew VIM could do
this! Wonder why this isn't default or a little easier to get to the default
behavior?

Now putting it all together into .vimrc (as I've got GVIM working above).

But now I notice I cannot use a value greater then 1 for both winminheight &
winminwidth. Using a value other then 0 or 1 (for both variables triggers the
following error on starting vim:

E591: 'winheight' cannot be smaller than 'winminheight': winminheight=2


I don't know about anybody else, but I think I'd prefer to see at least 1 (for
smaller displays), and maybe 3-4 for larger displays. But now I'm also seeing
how the incomplete text on the borders of the split windows can be distracting.
Again, user preference, ...etc.


---
Roger
http://rogerx.freeshell.org/

Tony Mechelynck

unread,
Oct 17, 2011, 8:58:44 AM10/17/11
to Roger, vim...@googlegroups.com
On 15/10/11 13:23, Roger wrote:
>> On Sun, Oct 09, 2011 at 11:37:56PM +0200, Tony Mechelynck wrote:
> For GVIM:

>
> nowfh was already default here.
>
> was ea, but I set to noea.
>
> eadirection=both was default too.
>
> set wmw& wmh is set to default 1?

>
>
> Now the culprit was your wiw, wh, hh, cwh, pvh values!
>
> My default values were set to something like these:
>
> winwidth=1
> winheight=1
> helpheight=20
> cmdwinheight=7
> previewheight=12
>
> And, once I used your wiw, wh, hh, cwh, pvh values, changing focus of the
> windowns and window resizing automagically happens now!
>
> The O'Reilly Learning VIM mentioned something about these values, but gave no
> real set values for a reader to try on his/her own VIM session. With your
> values, I'm now rolling on customizing to my liking!
>
> Next, I should be able to do this with CLI VIM(?).
>
> -- Roger
> http://rogerx.freeshell.org/
>

The snippet I proposed above should work equally well in console mode as
is does in GUI mode, provided that the executable was compiled with
+windows and (for the :let statement) with +eval.

Note that you can't really test +eval in a script, because in a Vim
compiled with -eval the :if...:endif construct is a nestable comment.
This shouldn't matter here since bracketing the whole snippet with :if
has('windows')...:endif will avoid errors in all cases � and we aren't
interested in split-windows' relative sizes when in a Vim which can't
even split windows.


Best regards,
Tony.
--
Don't believe everything you hear or anything you say.

Roger

unread,
Oct 19, 2011, 8:52:13 PM10/19/11
to Tony Mechelynck, vim...@googlegroups.com
>does in GUI mode...

It does and things are working well now. However I can see why VIM doesn't
have this feature on by default.

If you want to compare to files side by side (not using vimdiff), then one
needs to do some further hacking to get the windows back to equal size.

And just setting ":set noequalalways" doesn't magically resize the windows.
And if one manually resizes one window until both are back to equal size,
changing focus (ctrl+w+W) again reverts to the focused window taking full
screen size.

So, my next task is to hot-key a function key to "make windows equal".

But then when I get to this point, I ask myself why not just use tabs?

What joy. ;-)

Well, I can see where the idea of tabs likely originated!


>-- Don't believe everything you hear or anything you say.

--
Roger
http://rogerx.freeshell.org/

Reply all
Reply to author
Forward
0 new messages