Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does gVim resize and reposition itself after some actions?

Tags:

vim

aero-snap

I started using gVim a few weeks ago. From early on, I noticed however some strange resizing of the complete gVim window when I perform certain actions. I think it is related to my use of Windows Aero Snap (on a Windows 7 x64 system).

Steps to reproduce (with an empty .vimrc file, and my vimfiles folder renamed):

  1. I open gvim
  2. I put my gvim window to the left side of my monitor with (a few taps on) win+left arrow
  3. I create a new tab using :tabe

Result: gVim repositions itself somwehere else on the screen. So I have to reposition it using win+left arrow. Very annoying.

I have it with other tab and window actions as well, like: :vnew, C-W o, ...

Anybody any tips on why this is happening, and what i can do to fix it? I've already emptied my .vimrc file and temporarily renamed my ~/vimfiles folder to rule out the interference of any plugin.

Edit: Following Matthew's reply, and the info on :help bugs, I've send a bug report (this post actually) to [email protected]

like image 353
Rabarberski Avatar asked Nov 06 '12 12:11

Rabarberski


2 Answers

gvim can do this sort of thing in some situations with values of guioptions that make GUI controls such as scrollbars or tab page labels appear and disappear. Try the command :set guioptions?.

If the value displayed includes 'L' or 'R' (which optionally shows vertical scrollbars), it may be your culprit and you can remove the option as described below.

If it includes 'e', and especially if :set showtabline? shows that option = 1, that can also cause problems, and you could use the methods below to change either setting. (In this case the tab labels line only appears when there are at least two tabs.)

If it is neither of these, try and spot which parts of the GUI are appearing and disappearing when the problem occurs, and then find the option that controls that behaviour.

Example of how to fix if the problem value is 'L':

L is in the default settings, which are (from the help)

"egmrLtT"   (MS-Windows),
"aegimrLtT" (GTK, Motif and Athena).

You can therefore run one of these commands to fix it:

:set guioptions-=L  "just remove L
:set guioptions=egmrtT    "explicitly set the options you want, as noted you might want to remove 'e' as well

You can add one of these commands to your .vimrc file to always have it set.


You should definitely upgrade to a later build, there is certainly at least one bug in this area fixed since 7.3.46. That said, there are still problems as of 7.3.703.

The "Vim without Cream" install is well known to be reliable and kept quite up to date, and provides Vim without the Cream project addons. Future readers may find the bugs are fixed just by upgrading.

like image 116
lessthanideal Avatar answered Oct 13 '22 22:10

lessthanideal


A pull request was just merged in to Vim 8.0.1278. You can now add this following line to your config to alleviate the issue:

  • guioptions+=k

What this does is avoid resizing the window when adding a vertical split, tab, etc. This makes the window size more consistent in general, but would also avoid triggering the resizing issue you mentioned when the Vim window is pinned to the left/right side.

If you don't want to use this new option, the issue is in how Vim resizes. In the Windows build, it uses the restored window's position (which is different from when it's pinned to right/left as it's kind of in a maximized mode), so whenever the code tries to resize Vim for whatever reason it will reset the position to the restored window position as well. There're further discussions here: https://github.com/vim/vim/issues/2180

like image 26
ychin Avatar answered Oct 14 '22 00:10

ychin