简体   繁体   English

为什么gVim会在某些操作后调整大小并重新定位?

[英]Why does gVim resize and reposition itself after some actions?

I started using gVim a few weeks ago. 几个星期前我开始使用gVim From early on, I noticed however some strange resizing of the complete gVim window when I perform certain actions. 从早期开始,我注意到当我执行某些操作时,完整的gVim窗口会有一些奇怪的大小调整。 I think it is related to my use of Windows Aero Snap (on a Windows 7 x64 system). 我认为这与我使用Windows Aero Snap(在Windows 7 x64系统上)有关。

Steps to reproduce (with an empty .vimrc file, and my vimfiles folder renamed): 重现的步骤(使用空的.vimrc文件,重命名我的vimfiles文件夹):

  1. I open gvim 我打开gvim
  2. I put my gvim window to the left side of my monitor with (a few taps on) win + left arrow 我把我的gvim窗口放在显示器的左侧(点击几下) win + 左箭头
  3. I create a new tab using :tabe 我使用:tabe创建一个新选项卡

Result: gVim repositions itself somwehere else on the screen. 结果: gVim在屏幕上重新定位自己。 So I have to reposition it using win + left arrow . 所以我必须使用win + 左箭头重新定位它。 Very annoying. 很烦人。

I have it with other tab and window actions as well, like: :vnew , CW o , ... 我也可以使用其他制表符和窗口操作,例如:vnewCW 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. 我已经清空了我的.vimrc文件并临时重命名了我的〜/ vimfiles文件夹以排除任何插件的干扰。

Edit : Following Matthew's reply, and the info on :help bugs , I've send a bug report (this post actually) to bugs@vim.org 编辑 :关于Matthew的回复,以及关于:help bugs的信息,我发送了一个错误报告(实际上这篇文章)到bugs@vim.org

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. gvim可以在某些情况下执行此类操作,其中guioptions值会使GUI控件(如滚动条或标签页标签)出现和消失。 Try the command :set guioptions? 尝试命令: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. 如果显示的值包括“L”或“R”(可选择显示垂直滚动条),则可能是您的罪魁祸首,您可以按照以下说明删除该选项。

If it includes 'e', and especially if :set showtabline? 如果它包含'e',特别是如果:set showtabline? shows that option = 1, that can also cause problems, and you could use the methods below to change either setting. 显示option = 1,这也可能导致问题,您可以使用以下方法更改任一设置。 (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. 如果它们都不是这些,请尝试发现GUI的哪些部分出现并在问题发生时消失,然后找到控制该行为的选项。

Example of how to fix if the problem value is 'L': 如果问题值为“L”,如何修复的示例:

L is in the default settings, which are (from the help) L是默认设置,(来自帮助)

"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. 您可以将其中一个命令添加到.vimrc文件中,以便始终设置它。


You should definitely upgrade to a later build, there is certainly at least one bug in this area fixed since 7.3.46. 您肯定应该升级到以后的版本,自7.3.46以来,该区域肯定至少有一个错误。 That said, there are still problems as of 7.3.703. 也就是说,从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. 众所周知,“Vim without Cream”安装是可靠的并保持最新状态,并提供没有Cream项目插件的Vim。 Future readers may find the bugs are fixed just by upgrading. 未来的读者可能会发现只是通过升级来修复错误。

A pull request was just merged in to Vim 8.0.1278 . 拉取请求刚刚合并到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. 这样做是为了避免在添加垂直分割,制表符等时调整窗口大小。这使得窗口大小通常更加一致,但也可以避免触发Vim窗口固定到左/右侧时提到的调整大小问题。

If you don't want to use this new option, the issue is in how Vim resizes. 如果您不想使用此新选项,则问题在于Vim如何调整大小。 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. 在Windows构建中,它使用恢复窗口的位置(这与它在最大化模式下固定到右侧/左侧的位置不同),因此每当代码因任何原因尝试调整Vim大小时它将重置位置为恢复的窗口位置。 There're further discussions here: https://github.com/vim/vim/issues/2180 这里有进一步的讨论: https//github.com/vim/vim/issues/2180

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM