Gvim on Windows doesn't remember its position and size

2,947 views
Skip to first unread message

Дмитрий Франк

unread,
Oct 31, 2011, 1:05:20 AM10/31/11
to vim...@vim.org
Gvim on Windows doesn't remember its position and size.

I have two monitors, and Gvim always starts in the primary monitor and non-maximized. I have to everytime move it to another monitor and maximize. Other Windows applications remember its screen position and size, and start with the same parameters as it was closed.

It could be very useful if Gvim on Windows remind it too.

pic.gif

Ben Fritz

unread,
Oct 31, 2011, 10:44:31 AM10/31/11
to vim_dev
Maybe this will help? I haven't tried it.

http://vim.wikia.com/wiki/Restore_screen_size_and_position

Walt Elam

unread,
Oct 31, 2011, 7:33:40 AM10/31/11
to vim...@googlegroups.com


2011/10/31 Дмитрий Франк <dimon...@gmail.com>

Gvim on Windows doesn't remember its position and size.

I have two monitors, and Gvim always starts in the primary monitor and non-maximized. I have to everytime move it to another monitor and maximize. Other Windows applications remember its screen position and size, and start with the same parameters as it was closed.

           You can use the following attributes in the _vimrc file located in C:\Program Files\Vim:

            :winpos <x-position> <y-position>     "Set the x,y position of the gVim Window when gVim starts
            :set lines=<integer>                         "Set the number of rows that the gVim window has
            :set columns=<integer>                    "Set the number of columns that the gVim window has

It could be very useful if Gvim on Windows remind it too.

pic.gif

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Ben Fritz

unread,
Nov 2, 2011, 10:37:05 AM11/2/11
to vim_dev


On Oct 31, 6:33 am, Walt Elam <wre...@gmail.com> wrote:
> 2011/10/31 Дмитрий Франк <dimon.fr...@gmail.com>
>
> > Gvim on Windows doesn't remember its position and size.
>
> > I have two monitors, and Gvim always starts in the primary monitor and
> > non-maximized. I have to everytime move it to another monitor and maximize.
> > Other Windows applications remember its screen position and size, and start
> > with the same parameters as it was closed.
>
>            You can use the following attributes in the _vimrc file located
> in C:\Program Files\Vim:
>

A much better place would be the user-specific file instead of the
system-wide one, which additionally could get overwritten with every
new Vim install.

Go into Vim and do :echo $HOME to see where Vim found your $HOME
directory. Then create a file called either _vimrc or .vimrc in that
directory.

After you do this, you can actually refer to this file using the
$MYVIMRC environment variable, from within Vim.

Дмитрий Франк

unread,
Nov 3, 2011, 12:54:39 AM11/3/11
to vim...@googlegroups.com
            :winpos <x-position> <y-position>     "Set the x,y position of the gVim Window when gVim starts
            :set lines=<integer>                         "Set the number of rows that the gVim window has
            :set columns=<integer>                    "Set the number of columns that the gVim window has

i tried to use these variables, but there's anyway some troubles.
when gvim is opened in my secondary monitor and it is maximized, command ":winpos" returns "-1684 -4".
When i try to type ":winpos -1684 -4", gvim's window appears at the right place for a very little time (a part of second), and then instantly moves to main monitor, and ":winpos" returns "0 0" then. So, winpos is unfortunately unable to set negative values.

How can i fix this?

Thanks.

pic.gif
 

It could be very useful if Gvim on Windows remind it too.


--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Tony Mechelynck

unread,
Nov 3, 2011, 3:09:48 AM11/3/11
to vim...@googlegroups.com, Дмитрий Франк
On 03/11/11 05:54, Дмитрий Франк wrote:
>
> :winpos <x-position> <y-position> "Set the x,y position
> of the gVim Window when gVim starts
> :set lines=<integer> "Set the number of rows that the
> gVim window has
> :set columns=<integer> "Set the number of columns that
> the gVim window has
>
>
> i tried to use these variables, but there's anyway some troubles.
> when gvim is opened in my secondary monitor and it is maximized, command
> ":winpos" returns "-1684 -4".
> When i try to type ":winpos -1684 -4", gvim's window appears at the
> right place for a very little time (a part of second), and then
> instantly moves to main monitor, and ":winpos" returns "0 0" then. So,
> winpos is unfortunately unable to set negative values.
>
> How can i fix this?
>
> Thanks.

Hmm, IIUC Vim doesn't know about multiple monitors, or about the fact
that negative coordinates might be meaningful: so when it moves or
resizes the Vim screen (moves with :winpos, resizes by changing 'lines'
'columns' or, in gvim, 'guifont') it will try to adjust its coordinates
so that:

0 <= Xmin < Xmax <= Width
0 <= Ymin < Ymax <= Height

where Xmin, Xmax, Ymin, Ymax refer to the Vim screen, Width and Height
to your monitor. This will of course backfire if you try to move the Vim
screen to a secondary monitor, especially if it is located above or to
the left of the primary.

You could try naming your topleftmost monitor the primary, but only
experiment will tell if it will work.


Best regards,
Tony.
--
Fudd's First Law of Opposition:
Push something hard enough and it will fall over.

Дмитрий Франк

unread,
Nov 3, 2011, 3:18:14 AM11/3/11
to Tony Mechelynck, vim...@googlegroups.com


3 ноября 2011 г. 11:09 пользователь Tony Mechelynck <antoine.m...@gmail.com> написал:

On 03/11/11 05:54, Дмитрий Франк wrote:
Hmm, IIUC Vim doesn't know about multiple monitors, or about the fact that negative coordinates might be meaningful: so when it moves or resizes the Vim screen (moves with :winpos, resizes by changing 'lines' 'columns' or, in gvim, 'guifont') it will try to adjust its coordinates so that:

       0 <= Xmin < Xmax <= Width
       0 <= Ymin < Ymax <= Height

But could you please change this behaviour?  Personally i need to make my right monitor to be primary, and, after all, you see that negative coordinates is meaningful. Actually, even if Gvim stays in primary monitor, but it is maximized, then coordinates is "-4 -4" - it is negative again.

Something wrong.

Дмитрий Франк

unread,
Nov 3, 2011, 3:22:16 AM11/3/11
to Tony Mechelynck, vim...@googlegroups.com


3 ноября 2011 г. 11:18 пользователь Дмитрий Франк <dimon...@gmail.com> написал:



3 ноября 2011 г. 11:09 пользователь Tony Mechelynck <antoine.m...@gmail.com> написал:
On 03/11/11 05:54, Дмитрий Франк wrote:
Hmm, IIUC Vim doesn't know about multiple monitors, or about the fact that negative coordinates might be meaningful: so when it moves or resizes the Vim screen (moves with :winpos, resizes by changing 'lines' 'columns' or, in gvim, 'guifont') it will try to adjust its coordinates so that:

       0 <= Xmin < Xmax <= Width
       0 <= Ymin < Ymax <= Height

But could you please change this behaviour?  Personally i need to make my right monitor to be primary, and, after all, you see that negative coordinates is meaningful. Actually, even if Gvim stays in primary monitor, but it is maximized, then coordinates is "-4 -4" - it is negative again.

now this isn't legal to use bang  ( :winpos! ), so, maybe, the better way is to make it legal, and to not check if values is negative in this case.  
I mean, ":winpos -4 -4" should set position to "0 0", but   ":winpos! -4 -4"    should really set position to "-4 -4"  

Walt Elam

unread,
Nov 3, 2011, 11:58:38 AM11/3/11
to vim...@googlegroups.com


2011/11/3 Дмитрий Франк <dimon...@gmail.com>


            :winpos <x-position> <y-position>     "Set the x,y position of the gVim Window when gVim starts
            :set lines=<integer>                         "Set the number of rows that the gVim window has
            :set columns=<integer>                    "Set the number of columns that the gVim window has

i tried to use these variables, but there's anyway some troubles.
when gvim is opened in my secondary monitor and it is maximized, command ":winpos" returns "-1684 -4".
When i try to type ":winpos -1684 -4", gvim's window appears at the right place for a very little time (a part of second), and then instantly moves to main monitor, and ":winpos" returns "0 0" then. So, winpos is unfortunately unable to set negative values.

How can i fix this?

Ah, I see your problem now. Have you tried setting winpos in the opposite way? Instead of a negative value try using the equivalent positive value. Also, the y axis origin should still be the top of the monitor so I'm not entirely sure how it is returning a negative y-value when issuing :winpos.

Example: two monitors that are 1680x1050, and you want the position to be equivalent to :winpos -4 -4

x: 2(1680) + <x-position>
y: <y-position>

so try

:winpos 3356 -4

Again, I'm very confused about the y-position, having a negative y-position indicates that the GVim menu bar would be slightly off of the screen which doesn't seem useful, especially by only 4 pixels.

In addition, I just tested this on a single monitor machine and setting the x and y values higher than the resolution successfully put the GVim window off of the screen, so I'm hoping it will essentially "wrap-around" for you.

Дмитрий Франк

unread,
Nov 6, 2011, 11:42:33 PM11/6/11
to vim...@googlegroups.com

3 ноября 2011 г. 19:58 пользователь Walt Elam <wre...@gmail.com> написал:



2011/11/3 Дмитрий Франк <dimon...@gmail.com>

            :winpos <x-position> <y-position>     "Set the x,y position of the gVim Window when gVim starts
            :set lines=<integer>                         "Set the number of rows that the gVim window has
            :set columns=<integer>                    "Set the number of columns that the gVim window has

i tried to use these variables, but there's anyway some troubles.
when gvim is opened in my secondary monitor and it is maximized, command ":winpos" returns "-1684 -4".
When i try to type ":winpos -1684 -4", gvim's window appears at the right place for a very little time (a part of second), and then instantly moves to main monitor, and ":winpos" returns "0 0" then. So, winpos is unfortunately unable to set negative values.

How can i fix this?

Ah, I see your problem now. Have you tried setting winpos in the opposite way? Instead of a negative value try using the equivalent positive value. Also, the y axis origin should still be the top of the monitor so I'm not entirely sure how it is returning a negative y-value when issuing :winpos.

Example: two monitors that are 1680x1050, and you want the position to be equivalent to :winpos -4 -4

x: 2(1680) + <x-position>
y: <y-position>

so try

:winpos 3356 -4

Again, I'm very confused about the y-position, having a negative y-position indicates that the GVim menu bar would be slightly off of the screen which doesn't seem useful, especially by only 4 pixels.

In addition, I just tested this on a single monitor machine and setting the x and y values higher than the resolution successfully put the GVim window off of the screen, so I'm hoping it will essentially "wrap-around" for you.

Hi.

Unfortunately, this not helped: setting the x and y values higher than the resolution successfully really put the GVim window off of the screen, but i can't make Gvim put itself on the *left* monitor.
about -4 -4 : i'm sure this is Windows XP issue. When app is maximized, there's no border shown, and this border is 4 pixels width. I need to test it on Linux machine.

By the way, you successfully guessed: i have two monitors exactly 1680x1050 :)  and my right monitor is primary, left monitor is secondary. So, i still can't put Gvim window to the *left* monitor, because of (0; 0) point is a left-top corner of right monitor.

Дмитрий Франк

unread,
Nov 13, 2011, 10:43:53 AM11/13/11
to vim...@googlegroups.com
Dear Vim developers, so do you plan to allow negative values for :winpos in future?


7 ноября 2011 г. 8:42 пользователь Дмитрий Франк <dimon...@gmail.com> написал:

Christian Brabandt

unread,
Nov 15, 2011, 6:05:45 AM11/15/11
to vim...@googlegroups.com
On Sun, November 13, 2011 4:43 pm, ������� ����� wrote:
> Dear Vim developers, so do you plan to allow negative values for :winpos
> in future?

Vim doesn't care, whether the values are negative or positive. I can
successfully use negative values using either the Windows built or the
GTK built. What Gui are you using? It sounds rather like an issue with
your gui toolkit.

regards,
Christian

John Little

unread,
Nov 16, 2011, 12:37:22 AM11/16/11
to vim_dev
Christian Brabandt said:

> Vim doesn't care, whether the values are negative or positive. I can
> successfully use negative values using either the Windows built or the
> GTK built. What Gui are you using? It sounds rather like an issue with
> your gui toolkit.

Er... on my gvim 7.3.353 "Huge version with GTK2-GNOME GUI", negative
arguments to winpos are coerced to 0, as I would expect from :h
winpos:

"The position is adjusted to make the window fit on the screen (if
possible)."

I imagine the OP doesn't want this "adjustment".

Regards, John

Christian Brabandt

unread,
Nov 16, 2011, 3:51:05 AM11/16/11
to vim...@googlegroups.com

Seems to depend on your window manager. I don't know, why gnome
would reset it back to zero. Fluxbox/Openbox don't do it and allow to
set negative values (and so does Windows).

All that Vim does is calling gtk_window_move() with the new x and y
values and the documentation at http://developer.gnome.org/gtk/stable/
does not mention, that negative values are forbidden. Might be still
some unwanted effect in the way vim uses the gtk-toolkit.

regards,
Christian

Дмитрий Франк

unread,
Nov 17, 2011, 4:55:28 AM11/17/11
to vim...@googlegroups.com


15 ноября 2011 г. 15:05 пользователь Christian Brabandt <cbl...@256bit.org> написал:

On Sun, November 13, 2011 4:43 pm, Дмитрий Франк wrote:
> Dear Vim developers, so do you plan to allow negative values for :winpos
> in future?

Vim doesn't care, whether the values are negative or positive. I can
successfully use negative values using either the Windows built or the
GTK built. What Gui are you using? It sounds rather like an issue with
your gui toolkit.

I use standard Windows explorer.
 

regards,
Christian

Christian Brabandt

unread,
Nov 18, 2011, 7:04:52 AM11/18/11
to vim...@googlegroups.com
Hi Дмитрий!

On Do, 17 Nov 2011, Дмитрий Франк wrote:

> 15 ноября 2011 г. 15:05 пользователь Christian Brabandt
> <cbl...@256bit.org>написал:
>
> > On Sun, November 13, 2011 4:43 pm, Дмитрий Франк wrote:
> > > Dear Vim developers, so do you plan to allow negative values for :winpos
> > > in future?
> >
> > Vim doesn't care, whether the values are negative or positive. I can
> > successfully use negative values using either the Windows built or the
> > GTK built. What Gui are you using? It sounds rather like an issue with
> > your gui toolkit.
> >
>
> I use standard Windows explorer.

Please be more specific. What Windows version, what patch of vim? As I
said, I could use negative values on my Windows XP system at work, using
Vim 7.3.44 (or whatever the latest built from www.vim.org is).

regards,
Christian
--

Дмитрий Франк

unread,
Nov 29, 2011, 4:10:15 AM11/29/11
to vim...@googlegroups.com
Sorry that so long.

I have been using Gvim 7.3 without any patches, and negative values on it wasn't work. I have installed Gvim from www.vim.org recently, and its behavior is better, but anyway doesn't work as it should work.

To make Gvim full-screen in my left monitor, i need to do the following:

1) :winpos -1684 -4
2) :set lines=67
3) :set columns=237

1) i do:
:winpos -1684 -4
Gvim correctly stays on the proper place.

2) i do:
:set lines=67
And then Gvim changes its winpos to 0 0 again!

So, it allows to set negative values to :winpos, but setting lines or columns resets winpos.

Jürgen Krämer

unread,
Nov 30, 2011, 12:53:02 AM11/30/11
to vim...@googlegroups.com

Hi,

Дмитрий Франк wrote:
> Sorry that so long.
>

> I have been using Gvim 7.3 without any patches, and negative values on it wasn't work. I have installed Gvim from www.vim.org <http://www.vim.org> recently, and its behavior is better, but anyway doesn't work as it should work.


>
> To make Gvim full-screen in my left monitor, i need to do the following:
>
> 1) :winpos -1684 -4
> 2) :set lines=67
> 3) :set columns=237
>
> 1) i do:
> :winpos -1684 -4
> Gvim correctly stays on the proper place.
>
> 2) i do:
> :set lines=67
> And then Gvim changes its winpos to 0 0 again!

Whenever you set the 'lines' or 'columns' option to a new value GVim
tries to make sure that all lines and columns are visible on the screen
(at least this seems to be the case on Windows).

> So, it allows to set negative values to :winpos, but setting lines or columns resets winpos.

Just switch the order of your commands

1) :set lines=67
2) :set columns=237
3) :winpos -1684 -4

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)

Дмитрий Франк

unread,
Nov 30, 2011, 1:48:10 AM11/30/11
to vim...@googlegroups.com
Just switch the order of your commands

 1) :set lines=67
 2) :set columns=237
 3) :winpos -1684 -4

Regards,
Jürgen


I tried to do so, but my primary monitor (this is a monitor in which Vim starts) is less than secondary, so, :set lines=67 and columns=237 will actually set less values.
Could you please make a way to make Vim not to check if there enough space to show needed lines and columns count?
 
--
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)

Jürgen Krämer

unread,
Nov 30, 2011, 2:07:23 AM11/30/11
to vim...@googlegroups.com

Дмитрий Франк schrieb:


>
> Just switch the order of your commands
>
> 1) :set lines=67
> 2) :set columns=237
> 3) :winpos -1684 -4
>
> Regards,
> Jürgen
>
>
> I tried to do so, but my primary monitor (this is a monitor in which Vim starts) is less than secondary, so, :set lines=67 and columns=237 will actually set less values.
> Could you please make a way to make Vim not to check if there enough space to show needed lines and columns count?

I haven't followed the whole thread so please excuse me if you already
have said it: Do you want to maximize the window on the monitor (-4 is
a typical value for maximized windows on Windows)? If so you might try

:winpos -1680 0
:simalt ~X

where you have to replace the "X" in the second command with the letter
that is underlined in the "Maximize" menu item of GVim's system menu
(the one in the upper left corner of the title bar).

Regards,
Jürgen

Дмитрий Франк

unread,
Nov 30, 2011, 2:44:06 AM11/30/11
to vim...@googlegroups.com


2011/11/30 Jürgen Krämer <jott...@googlemail.com>

 
 
Дмитрий Франк schrieb:
>
>     Just switch the order of your commands
>
>      1) :set lines=67
>      2) :set columns=237
>      3) :winpos -1684 -4
>
>     Regards,
>     Jürgen
>
>
> I tried to do so, but my primary monitor (this is a monitor in which Vim starts) is less than secondary, so, :set lines=67 and columns=237 will actually set less values.
> Could you please make a way to make Vim not to check if there enough space to show needed lines and columns count?

I haven't followed the whole thread so please excuse me if you already
have said it: Do you want to maximize the window on the monitor (-4 is
a typical value for maximized windows on Windows)? If so you might try

 :winpos -1680 0
 :simalt ~X

where you have to replace the "X" in the second command with the letter
that is underlined in the "Maximize" menu item of GVim's system menu
(the one in the upper left corner of the title bar).

Regards,
Jürgen


this could be a great solution if only Windows hadn't been so stupid. Now I'll explain:
I use cyrillic Windows, and my combination for maximize window is Alt+Spacebar+Р  (Р is a cyrillic letter).

But command :simalt ~Р unfortunately works if only current layout is cyrillic! I mean that i type :simalt ~Р, and current layout is cyrillic, i press enter, and this works. Then i change layout to default english, type :<up>  (previous command appears at command-line), press enter, end, damn, it doesn't work.

Maybe is there workaround in Vim to simulate Windows layout change? Or any other workaround?
 
--
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)

Reply all
Reply to author
Forward
0 new messages