How to open gvim on windows maximized....??

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How to open gvim on windows maximized....??

Ankur Nayak
Hi,
sorry if it is a trivial question. i searched the archives as well as
the help but to no good results. Whenever I open gvim on windows it
always opens in a small window and everytime i have to maxmize it
manually. Is there any way by which I can open gvim in such a way that
it opens as maximized.

Thanks
ankur
Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

Tim Chase-2
> sorry if it is a trivial question. i searched the archives as
> well as the help but to no good results. Whenever I open gvim
> on windows it always opens in a small window and everytime i
> have to maxmize it manually. Is there any way by which I can
> open gvim in such a way that it opens as maximized.


In Windows, it takes combining two bits: auto-commands and "simalt"

    :help autocmd
    :he GUIEnter
    :he simalt

The final line for your gvimrc would read

    autocmd GUIEnter * simalt ~X

This means "when you start up the GUI for the first time, on any
type of buffer, send the windows 'alt-space' and hit X to maximize".

With non-Win32 platforms there may be other things you can use.
However, I suspect that a combination of "winpos" and setting the
lines and columns, something like

    autocmd GUIEnter * winpos 0 0 | set lines=9999 columns=9999

would do the job for you, though it won't open the window in a
state the system would recognize as "maximized"...just "a really
big window".  Vim does resize its window to the screen, so it
will be maximized in effect.

Hope this helps,

-tim




Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

A.J.Mechelynck
In reply to this post by Ankur Nayak
----- Original Message -----
From: "Ankur Nayak" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, August 10, 2005 7:49 PM
Subject: How to open gvim on windows maximized....??


> Hi,
> sorry if it is a trivial question. i searched the archives as well as
> the help but to no good results. Whenever I open gvim on windows it
> always opens in a small window and everytime i have to maxmize it
> manually. Is there any way by which I can open gvim in such a way that
> it opens as maximized.
>
> Thanks
> ankur

The has been discussed many times in this list.

The most portable answer is:

    if has("gui_running")
        if exists(":winpos") == 2
            winpos 0 0
        endif
        set lines=99999 columns=99999
    endif

Add the above to your vimrc and on you go. The ifs are there to avoid
maximizing the Dos box if you run console Vim, and to avoid error messages
if (for instance on a multi-boot system) you ever run a version of Vim which
doesn't have the ":winpos" command.

You can also do it using ":simalt" to mimic using the Alt-Space -> Maximize
menu, but the hotkey varies from language to language. (I've had a
Dutch-language Windows installed on me when replacing the hard disk after a
head crash under warranty, and I know what I'm talking about.)

Whichever method you use, if you also change the 'guifont' you should set
the font first and maximize the window afterwards, as follows:

    if has("gui_running")
        set guifont=Lucida_Console:h8:cDEFAULT
        if exists(":winpos") == 2
            winpos 0 0
        endif
        set lines=99999 columns=99999
    endif


HTH,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

Ankur Nayak
In reply to this post by Tim Chase-2
But this means that gvim always opens in a minimized state. I got your
method. You pass the key combination to the GUI so that it makes the
minimized window maximized. But is there any way by which it can be
allowed to straightway open in maximized state. Your method would work
though.
One more thing....If i want to do it on linux, then what is the
similar command.....say if i have binded Alt-<F10> as the maximizing
key. Just replaceing "simalt ~X" with "simalt<F10" would do???

Thanks for the help....

On 8/10/05, Tim Chase <[hidden email]> wrote:

> > sorry if it is a trivial question. i searched the archives as
> > well as the help but to no good results. Whenever I open gvim
> > on windows it always opens in a small window and everytime i
> > have to maxmize it manually. Is there any way by which I can
> > open gvim in such a way that it opens as maximized.
>
>
> In Windows, it takes combining two bits: auto-commands and "simalt"
>
>     :help autocmd
>     :he GUIEnter
>     :he simalt
>
> The final line for your gvimrc would read
>
>     autocmd GUIEnter * simalt ~X
>
> This means "when you start up the GUI for the first time, on any
> type of buffer, send the windows 'alt-space' and hit X to maximize".
>
> With non-Win32 platforms there may be other things you can use.
> However, I suspect that a combination of "winpos" and setting the
> lines and columns, something like
>
>     autocmd GUIEnter * winpos 0 0 | set lines=9999 columns=9999
>
> would do the job for you, though it won't open the window in a
> state the system would recognize as "maximized"...just "a really
> big window".  Vim does resize its window to the screen, so it
> will be maximized in effect.
>
> Hope this helps,
>
> -tim
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

A.J.Mechelynck
----- Original Message -----
From: "Ankur Nayak" <[hidden email]>
To: "Tim Chase" <[hidden email]>
Cc: <[hidden email]>
Sent: Wednesday, August 10, 2005 8:13 PM
Subject: Re: How to open gvim on windows maximized....??


> But this means that gvim always opens in a minimized state. I got your
> method. You pass the key combination to the GUI so that it makes the
> minimized window maximized. But is there any way by which it can be
> allowed to straightway open in maximized state. Your method would work
> though.
> One more thing....If i want to do it on linux, then what is the
> similar command.....say if i have binded Alt-<F10> as the maximizing
> key. Just replaceing "simalt ~X" with "simalt<F10" would do???
>
> Thanks for the help....
[...]

Setting 'lines' and 'columns' work across all GUI versions. Sometimes it's
off by one line or column but that shouldn't be of much concern. If you set
them during startup, before the GUI is opened, the values will be remembered
until they can be used.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

Tim Chase-2
In reply to this post by Ankur Nayak
>>> Whenever I open gvim on windows it always opens in a small
>>>  window and everytime i have to maxmize it manually.
:
:
> But this means that gvim always opens in a minimized state.

Did you use the "~x" that I wrote rather than "~n" that the help
uses?  The one in the help minimizes ("Mi(n)imize") rather than
maximizes ("Ma(x)imize").  Or possibly (as per Tony's flash of
insight) are you running gvim in a non-English version of
Windows?  The letter on the system menu might be something other
than "x".

> You pass the key combination to the GUI so that it makes the
> minimized window maximized.

Yes.

> But is there any way by which it can be allowed to straightway
>  open in maximized state.

By putting it in the GUIEnter autocmd, it's as early as anything
can be done in the gui.  Another alternative would be to use,
from a command prompt

        start /max gvim

(assuming your gvimrc doesn't bung with them elsewise)

> want to do it on linux, then what is the similar
> command.....say if i have binded Alt-<F10> as the maximizing
> key. Just replaceing "simalt ~X" with "simalt<F10" would do???

The winpos/lines/column solution should work.  I don't know about
the simalt solution, as all my access to Linux boxen at the
moment is via SSH from my work Win32 box, so I'm using just
console vim, not gvim.  No harm in trying it though.  If it
works, I suspect it would be configuration-specific, or possibly
window-manager-specific.

-tim




Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

J.C. Roberts-2
In reply to this post by Ankur Nayak
On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
wrote:

>Hi,
>sorry if it is a trivial question. i searched the archives as well as
>the help but to no good results. Whenever I open gvim on windows it
>always opens in a small window and everytime i have to maxmize it
>manually. Is there any way by which I can open gvim in such a way that
>it opens as maximized.
>
>Thanks
>ankur

The easiest solution has nothing to do with (re)programming the vim
startup. On MS-Windows, you have links (shortcuts) to your
applications. The location of the shortcut you see in your "Start
Button" menu, depends on the type of MS-Windows system you're running
and where/how vim was installed but in general, look for a directory
named "Start Menu"

Right click on the vim shortcut, choose "Properties" go to the
"Shortcut" tab and look for the dropdown box named "Run" select
"Maximized" from the list, click Apply click OK.

JCR
Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

A.J.Mechelynck
----- Original Message -----
From: "J.C. Roberts" <[hidden email]>
To: "Ankur Nayak" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 11, 2005 8:23 AM
Subject: Re: How to open gvim on windows maximized....??


> On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
> wrote:
>
>>Hi,
>>sorry if it is a trivial question. i searched the archives as well as
>>the help but to no good results. Whenever I open gvim on windows it
>>always opens in a small window and everytime i have to maxmize it
>>manually. Is there any way by which I can open gvim in such a way that
>>it opens as maximized.
>>
>>Thanks
>>ankur
>
> The easiest solution has nothing to do with (re)programming the vim
> startup. On MS-Windows, you have links (shortcuts) to your
> applications. The location of the shortcut you see in your "Start
> Button" menu, depends on the type of MS-Windows system you're running
> and where/how vim was installed but in general, look for a directory
> named "Start Menu"
>
> Right click on the vim shortcut, choose "Properties" go to the
> "Shortcut" tab and look for the dropdown box named "Run" select
> "Maximized" from the list, click Apply click OK.
>
> JCR

Maybe the easiest, but certainly the least general, as it applies _only_ to
Vim sessions started by clicking on that particular shortcut, and not by any
other means such as using the "Edit with Vim" menu item in the right-click
context menu, typing gvim at the prompt in a Dos box, invoking gvim from a
.BAT script, using gvim as auxiliary editor called from another application,
or even by using a different shortcut, since you may have several, e.g., one
in the Start menu, one on the desktop, one in the Quick Launch toolbar, etc.
OTOH anything in $HOME/_vimrc applies to any Vim session for that user, and
anything in $VIM/vimrc applies to any Vim session for any user.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

J.C. Roberts-2
On Thu, 11 Aug 2005 08:54:49 +0200, "Tony Mechelynck"
<[hidden email]> wrote:

>----- Original Message -----
>From: "J.C. Roberts" <[hidden email]>
>To: "Ankur Nayak" <[hidden email]>
>Cc: <[hidden email]>
>Sent: Thursday, August 11, 2005 8:23 AM
>Subject: Re: How to open gvim on windows maximized....??
>
>
>> On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
>> wrote:
>>
>>>Hi,
>>>sorry if it is a trivial question. i searched the archives as well as
>>>the help but to no good results. Whenever I open gvim on windows it
>>>always opens in a small window and everytime i have to maxmize it
>>>manually. Is there any way by which I can open gvim in such a way that
>>>it opens as maximized.
>>>
>>>Thanks
>>>ankur
>>
>> The easiest solution has nothing to do with (re)programming the vim
>> startup. On MS-Windows, you have links (shortcuts) to your
>> applications. The location of the shortcut you see in your "Start
>> Button" menu, depends on the type of MS-Windows system you're running
>> and where/how vim was installed but in general, look for a directory
>> named "Start Menu"
>>
>> Right click on the vim shortcut, choose "Properties" go to the
>> "Shortcut" tab and look for the dropdown box named "Run" select
>> "Maximized" from the list, click Apply click OK.
>>
>> JCR
>
>Maybe the easiest, but certainly the least general, as it applies _only_ to
>Vim sessions started by clicking on that particular shortcut, and not by any
>other means such as using the "Edit with Vim" menu item in the right-click
>context menu, typing gvim at the prompt in a Dos box, invoking gvim from a
>.BAT script, using gvim as auxiliary editor called from another application,
>or even by using a different shortcut, since you may have several, e.g., one
>in the Start menu, one on the desktop, one in the Quick Launch toolbar, etc.
>OTOH anything in $HOME/_vimrc applies to any Vim session for that user, and
>anything in $VIM/vimrc applies to any Vim session for any user.
>
>Best regards,
>Tony.
>

Tony,

You definitely have a point about other startup methods but to be
fair, I really didn't want to go into all the various MS-Windows
hacking it would require to cover all methods.

The MS-Windows "shortcut" is just a file with a (very) hidden
extension (*.lnk) and they are executable from the command line. All
arguments passed to the invoked shortcut will be passed to the
executable and work the same. It takes a bit of registry hacking to
reveal the shortcut extension but it is possible, even though it's
basically unnecessary.

You can run the shortcut from the command line or in batch files or
where ever you like and you can copy it to the Quick Launch bar,
Desktop, start menu or anywhere. In other words, you've got something
that basically works like any other executable.

Explorer extensions (i.e. file manager right click menu items) are
configurable through the registry. You can point the "Edit With Vim"
to use your modified shortcut and you get the desired affect.

The only thing you can not do (without serious modification of the OS)
with a shortcuts is create a shortcut that points to another shortcut.

Is it going to work on all MS-Windows start methods? -Yes.
Is it portable? -Nope.
Is hacking the vimrc easier? -Probably.
Is hacking up MS-Windows to work right a pain in the ass? -YES!

You're basically right in theory since nobody really knows windows
internals anymore but in practice, you're technically wrong since it
is possible to do.

"In theory there's no difference between practice and theory but in
practice there is."
        --Yogi Beara

:-)

Kind Regards,
JCR
Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

A.J.Mechelynck
----- Original Message -----
From: "J.C. Roberts" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 11, 2005 9:25 AM
Subject: Re: How to open gvim on windows maximized....??


> On Thu, 11 Aug 2005 08:54:49 +0200, "Tony Mechelynck"
> <[hidden email]> wrote:
>
>>----- Original Message -----
>>From: "J.C. Roberts" <[hidden email]>
>>To: "Ankur Nayak" <[hidden email]>
>>Cc: <[hidden email]>
>>Sent: Thursday, August 11, 2005 8:23 AM
>>Subject: Re: How to open gvim on windows maximized....??
>>
>>
>>> On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
>>> wrote:
>>>
>>>>Hi,
>>>>sorry if it is a trivial question. i searched the archives as well as
>>>>the help but to no good results. Whenever I open gvim on windows it
>>>>always opens in a small window and everytime i have to maxmize it
>>>>manually. Is there any way by which I can open gvim in such a way that
>>>>it opens as maximized.
>>>>
>>>>Thanks
>>>>ankur
>>>
>>> The easiest solution has nothing to do with (re)programming the vim
>>> startup. On MS-Windows, you have links (shortcuts) to your
>>> applications. The location of the shortcut you see in your "Start
>>> Button" menu, depends on the type of MS-Windows system you're running
>>> and where/how vim was installed but in general, look for a directory
>>> named "Start Menu"
>>>
>>> Right click on the vim shortcut, choose "Properties" go to the
>>> "Shortcut" tab and look for the dropdown box named "Run" select
>>> "Maximized" from the list, click Apply click OK.
>>>
>>> JCR
>>
>>Maybe the easiest, but certainly the least general, as it applies _only_
>>to
>>Vim sessions started by clicking on that particular shortcut, and not by
>>any
>>other means such as using the "Edit with Vim" menu item in the right-click
>>context menu, typing gvim at the prompt in a Dos box, invoking gvim from a
>>.BAT script, using gvim as auxiliary editor called from another
>>application,
>>or even by using a different shortcut, since you may have several, e.g.,
>>one
>>in the Start menu, one on the desktop, one in the Quick Launch toolbar,
>>etc.
>>OTOH anything in $HOME/_vimrc applies to any Vim session for that user,
>>and
>>anything in $VIM/vimrc applies to any Vim session for any user.
>>
>>Best regards,
>>Tony.
>>
>
> Tony,
>
> You definitely have a point about other startup methods but to be
> fair, I really didn't want to go into all the various MS-Windows
> hacking it would require to cover all methods.
>
> The MS-Windows "shortcut" is just a file with a (very) hidden
> extension (*.lnk) and they are executable from the command line. All
> arguments passed to the invoked shortcut will be passed to the
> executable and work the same. It takes a bit of registry hacking to
> reveal the shortcut extension but it is possible, even though it's
> basically unnecessary.
>
> You can run the shortcut from the command line or in batch files or
> where ever you like and you can copy it to the Quick Launch bar,
> Desktop, start menu or anywhere. In other words, you've got something
> that basically works like any other executable.
>
> Explorer extensions (i.e. file manager right click menu items) are
> configurable through the registry. You can point the "Edit With Vim"
> to use your modified shortcut and you get the desired affect.
>
> The only thing you can not do (without serious modification of the OS)
> with a shortcuts is create a shortcut that points to another shortcut.
>
> Is it going to work on all MS-Windows start methods? -Yes.
> Is it portable? -Nope.
> Is hacking the vimrc easier? -Probably.
> Is hacking up MS-Windows to work right a pain in the ass? -YES!
>
> You're basically right in theory since nobody really knows windows
> internals anymore but in practice, you're technically wrong since it
> is possible to do.
>
> "In theory there's no difference between practice and theory but in
> practice there is."
> --Yogi Beara
>
> :-)
>
> Kind Regards,
> JCR

You've got a strange conception of what is "theory" and what is "practice".
I admit I may be "technically" wrong "in theory", but "in practice" the
registry is esoteric, ill-documented, and proprietary to Micro$oft while the
vimrc is well-documented, in plaintext, and reasonably cross-platform (and
can be made really cross-platform, e.g. on dual-boot systems, by means of a
few "if" statements). For this reason, I would not call setting up a vimrc
"hacking" but if you can customize your registry in your sleep you might see
matters differently. ;-)

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

J.C. Roberts-2
On Thu, 11 Aug 2005 10:40:33 +0200, "Tony Mechelynck"
<[hidden email]> wrote:

>----- Original Message -----
>From: "J.C. Roberts" <[hidden email]>
>To: "Tony Mechelynck" <[hidden email]>
>Cc: <[hidden email]>
>Sent: Thursday, August 11, 2005 9:25 AM
>Subject: Re: How to open gvim on windows maximized....??
>
>
>> On Thu, 11 Aug 2005 08:54:49 +0200, "Tony Mechelynck"
>> <[hidden email]> wrote:
>>
>>>----- Original Message -----
>>>From: "J.C. Roberts" <[hidden email]>
>>>To: "Ankur Nayak" <[hidden email]>
>>>Cc: <[hidden email]>
>>>Sent: Thursday, August 11, 2005 8:23 AM
>>>Subject: Re: How to open gvim on windows maximized....??
>>>
>>>
>>>> On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
>>>> wrote:
>>>>
>>>>>Hi,
>>>>>sorry if it is a trivial question. i searched the archives as well as
>>>>>the help but to no good results. Whenever I open gvim on windows it
>>>>>always opens in a small window and everytime i have to maxmize it
>>>>>manually. Is there any way by which I can open gvim in such a way that
>>>>>it opens as maximized.
>>>>>
>>>>>Thanks
>>>>>ankur
>>>>
>>>> The easiest solution has nothing to do with (re)programming the vim
>>>> startup. On MS-Windows, you have links (shortcuts) to your
>>>> applications. The location of the shortcut you see in your "Start
>>>> Button" menu, depends on the type of MS-Windows system you're running
>>>> and where/how vim was installed but in general, look for a directory
>>>> named "Start Menu"
>>>>
>>>> Right click on the vim shortcut, choose "Properties" go to the
>>>> "Shortcut" tab and look for the dropdown box named "Run" select
>>>> "Maximized" from the list, click Apply click OK.
>>>>
>>>> JCR
>>>
>>>Maybe the easiest, but certainly the least general, as it applies _only_
>>>to
>>>Vim sessions started by clicking on that particular shortcut, and not by
>>>any
>>>other means such as using the "Edit with Vim" menu item in the right-click
>>>context menu, typing gvim at the prompt in a Dos box, invoking gvim from a
>>>.BAT script, using gvim as auxiliary editor called from another
>>>application,
>>>or even by using a different shortcut, since you may have several, e.g.,
>>>one
>>>in the Start menu, one on the desktop, one in the Quick Launch toolbar,
>>>etc.
>>>OTOH anything in $HOME/_vimrc applies to any Vim session for that user,
>>>and
>>>anything in $VIM/vimrc applies to any Vim session for any user.
>>>
>>>Best regards,
>>>Tony.
>>>
>>
>> Tony,
>>
>> You definitely have a point about other startup methods but to be
>> fair, I really didn't want to go into all the various MS-Windows
>> hacking it would require to cover all methods.
>>
>> The MS-Windows "shortcut" is just a file with a (very) hidden
>> extension (*.lnk) and they are executable from the command line. All
>> arguments passed to the invoked shortcut will be passed to the
>> executable and work the same. It takes a bit of registry hacking to
>> reveal the shortcut extension but it is possible, even though it's
>> basically unnecessary.
>>
>> You can run the shortcut from the command line or in batch files or
>> where ever you like and you can copy it to the Quick Launch bar,
>> Desktop, start menu or anywhere. In other words, you've got something
>> that basically works like any other executable.
>>
>> Explorer extensions (i.e. file manager right click menu items) are
>> configurable through the registry. You can point the "Edit With Vim"
>> to use your modified shortcut and you get the desired affect.
>>
>> The only thing you can not do (without serious modification of the OS)
>> with a shortcuts is create a shortcut that points to another shortcut.
>>
>> Is it going to work on all MS-Windows start methods? -Yes.
>> Is it portable? -Nope.
>> Is hacking the vimrc easier? -Probably.
>> Is hacking up MS-Windows to work right a pain in the ass? -YES!
>>
>> You're basically right in theory since nobody really knows windows
>> internals anymore but in practice, you're technically wrong since it
>> is possible to do.
>>
>> "In theory there's no difference between practice and theory but in
>> practice there is."
>> --Yogi Beara
>>
>> :-)
>>
>> Kind Regards,
>> JCR
>
>You've got a strange conception of what is "theory" and what is "practice".
>I admit I may be "technically" wrong "in theory", but "in practice" the
>registry is esoteric, ill-documented, and proprietary to Micro$oft while the
>vimrc is well-documented, in plaintext, and reasonably cross-platform (and
>can be made really cross-platform, e.g. on dual-boot systems, by means of a
>few "if" statements). For this reason, I would not call setting up a vimrc
>"hacking" but if you can customize your registry in your sleep you might see
>matters differently. ;-)
>
>Best regards,
>Tony.
>

I'm absolutely *certain* we can agree on the MS-registry being
esoteric, proprietary and poorly documented while vimrc is well
documented and cross platform. ;-)

I took the liberty of hacking around in the registry with *.lnk files
to see what I could make of it. The process making them executable
from shell extensions is more convoluted that I remember.

The easy method is to patch the gvimext.dll and gvim.exe. I've
disassembled the former and figured out how it's getting to the
CreateProcessA() call. From there it's a matter of figuring out the
StartupInfoA structure lives and modifying the dwFlags element...
Patching binaries is probably out of the question for normal users.

Anyhow, at the moment vim uses the registry HKLM/Software/vim/gvim,
well, at least gvimext.dll does. It would not take much effort to set
things up such that on application load it checks the registry
HKLM/Software/vim/gvim for a "windowstate" value and on application
close, the current maximize/minimize status is saved to that value in
the registry. The result would be your window max/min would be based
on the "last use" of the application.

JCR
Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

A.J.Mechelynck
----- Original Message -----
From: "J.C. Roberts" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 11, 2005 11:43 AM
Subject: Re: How to open gvim on windows maximized....??


> On Thu, 11 Aug 2005 10:40:33 +0200, "Tony Mechelynck"
> <[hidden email]> wrote:
>
>>----- Original Message -----
>>From: "J.C. Roberts" <[hidden email]>
>>To: "Tony Mechelynck" <[hidden email]>
>>Cc: <[hidden email]>
>>Sent: Thursday, August 11, 2005 9:25 AM
>>Subject: Re: How to open gvim on windows maximized....??
>>
>>
>>> On Thu, 11 Aug 2005 08:54:49 +0200, "Tony Mechelynck"
>>> <[hidden email]> wrote:
>>>
>>>>----- Original Message -----
>>>>From: "J.C. Roberts" <[hidden email]>
>>>>To: "Ankur Nayak" <[hidden email]>
>>>>Cc: <[hidden email]>
>>>>Sent: Thursday, August 11, 2005 8:23 AM
>>>>Subject: Re: How to open gvim on windows maximized....??
>>>>
>>>>
>>>>> On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
>>>>> wrote:
>>>>>
>>>>>>Hi,
>>>>>>sorry if it is a trivial question. i searched the archives as well as
>>>>>>the help but to no good results. Whenever I open gvim on windows it
>>>>>>always opens in a small window and everytime i have to maxmize it
>>>>>>manually. Is there any way by which I can open gvim in such a way that
>>>>>>it opens as maximized.
>>>>>>
>>>>>>Thanks
>>>>>>ankur
>>>>>
>>>>> The easiest solution has nothing to do with (re)programming the vim
>>>>> startup. On MS-Windows, you have links (shortcuts) to your
>>>>> applications. The location of the shortcut you see in your "Start
>>>>> Button" menu, depends on the type of MS-Windows system you're running
>>>>> and where/how vim was installed but in general, look for a directory
>>>>> named "Start Menu"
>>>>>
>>>>> Right click on the vim shortcut, choose "Properties" go to the
>>>>> "Shortcut" tab and look for the dropdown box named "Run" select
>>>>> "Maximized" from the list, click Apply click OK.
>>>>>
>>>>> JCR
>>>>
>>>>Maybe the easiest, but certainly the least general, as it applies _only_
>>>>to
>>>>Vim sessions started by clicking on that particular shortcut, and not by
>>>>any
>>>>other means such as using the "Edit with Vim" menu item in the
>>>>right-click
>>>>context menu, typing gvim at the prompt in a Dos box, invoking gvim from
>>>>a
>>>>.BAT script, using gvim as auxiliary editor called from another
>>>>application,
>>>>or even by using a different shortcut, since you may have several, e.g.,
>>>>one
>>>>in the Start menu, one on the desktop, one in the Quick Launch toolbar,
>>>>etc.
>>>>OTOH anything in $HOME/_vimrc applies to any Vim session for that user,
>>>>and
>>>>anything in $VIM/vimrc applies to any Vim session for any user.
>>>>
>>>>Best regards,
>>>>Tony.
>>>>
>>>
>>> Tony,
>>>
>>> You definitely have a point about other startup methods but to be
>>> fair, I really didn't want to go into all the various MS-Windows
>>> hacking it would require to cover all methods.
>>>
>>> The MS-Windows "shortcut" is just a file with a (very) hidden
>>> extension (*.lnk) and they are executable from the command line. All
>>> arguments passed to the invoked shortcut will be passed to the
>>> executable and work the same. It takes a bit of registry hacking to
>>> reveal the shortcut extension but it is possible, even though it's
>>> basically unnecessary.
>>>
>>> You can run the shortcut from the command line or in batch files or
>>> where ever you like and you can copy it to the Quick Launch bar,
>>> Desktop, start menu or anywhere. In other words, you've got something
>>> that basically works like any other executable.
>>>
>>> Explorer extensions (i.e. file manager right click menu items) are
>>> configurable through the registry. You can point the "Edit With Vim"
>>> to use your modified shortcut and you get the desired affect.
>>>
>>> The only thing you can not do (without serious modification of the OS)
>>> with a shortcuts is create a shortcut that points to another shortcut.
>>>
>>> Is it going to work on all MS-Windows start methods? -Yes.
>>> Is it portable? -Nope.
>>> Is hacking the vimrc easier? -Probably.
>>> Is hacking up MS-Windows to work right a pain in the ass? -YES!
>>>
>>> You're basically right in theory since nobody really knows windows
>>> internals anymore but in practice, you're technically wrong since it
>>> is possible to do.
>>>
>>> "In theory there's no difference between practice and theory but in
>>> practice there is."
>>> --Yogi Beara
>>>
>>> :-)
>>>
>>> Kind Regards,
>>> JCR
>>
>>You've got a strange conception of what is "theory" and what is
>>"practice".
>>I admit I may be "technically" wrong "in theory", but "in practice" the
>>registry is esoteric, ill-documented, and proprietary to Micro$oft while
>>the
>>vimrc is well-documented, in plaintext, and reasonably cross-platform (and
>>can be made really cross-platform, e.g. on dual-boot systems, by means of
>>a
>>few "if" statements). For this reason, I would not call setting up a vimrc
>>"hacking" but if you can customize your registry in your sleep you might
>>see
>>matters differently. ;-)
>>
>>Best regards,
>>Tony.
>>
>
> I'm absolutely *certain* we can agree on the MS-registry being
> esoteric, proprietary and poorly documented while vimrc is well
> documented and cross platform. ;-)
>
> I took the liberty of hacking around in the registry with *.lnk files
> to see what I could make of it. The process making them executable
> from shell extensions is more convoluted that I remember.
>
> The easy method is to patch the gvimext.dll and gvim.exe. I've
> disassembled the former and figured out how it's getting to the
> CreateProcessA() call. From there it's a matter of figuring out the
> StartupInfoA structure lives and modifying the dwFlags element...
> Patching binaries is probably out of the question for normal users.
>
> Anyhow, at the moment vim uses the registry HKLM/Software/vim/gvim,
> well, at least gvimext.dll does. It would not take much effort to set
> things up such that on application load it checks the registry
> HKLM/Software/vim/gvim for a "windowstate" value and on application
> close, the current maximize/minimize status is saved to that value in
> the registry. The result would be your window max/min would be based
> on the "last use" of the application.
>
> JCR

Except, again, for portability. You would have to do that in gvim, not
gvimext, and there would be no corresponding mechanism for X11 or VMS. OTOH,
it's child's play to write a little function to save the winposx, winposy,
'lines' and 'columns' at the VimLeave event and restore them (if found) from
the vimrc. I've seen it but haven't written it down; let's treat it as an
exercise:

    if has("gui_running")
        function s:SaveWindow()
            " function to be called at the VimLeave event
            " create a vim script to be sourced at next startup
            redir! > ~/winpos.vim
            if &guifont != ""
                silent echo "set guifont=" . escape(&guifont,' "\')
            endif
            if exists(":winpos") == 2
                silent echo "winpos" getwinposx() getwinposy()
            endif
            silent echo "set lines=" . &lines "columns=" . &columns
            redir END
        endfunction
        autocmd VimLeave * call s:SaveWindow()
        " the argument to filereadable() must be a pathfilename
        " in the proper format for the current OS, not in Vim format
        if filereadable($HOME .
            \ ((exists("+shellslash) && &noshellslash)?'\':'/') .
            \ "winpos.vim")
            source ~/winpos.vim
        endif
    endif

Patching binaries is indeed probably out of question for most users, but
rather than patch the binaries, many programmers could (if they wanted to)
patch the sources, at the expense (of course) of the risks which come with
any branch in the code tree (and the added labour needed to port the
bugfixes from the "main" tree again and again). Vim is open source,
remember? and the sources of xxd.exe, gvimext.dll, vimrun.exe, install.exe
and uninstal.exe are also there (I recompile them almost every night). No
need to painstakingly disassemble. Anyway, given the choice, I'd rather add
a few lines to my vimrc than patch the C sources (main.c probably). It's
more general, more portable, and it doesn't run the risk of making the patch
program choke 20 bugfixes later on too big an offset.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

J.C. Roberts-2
On Thu, 11 Aug 2005 13:39:42 +0200, "Tony Mechelynck"
<[hidden email]> wrote:

>----- Original Message -----
>From: "J.C. Roberts" <[hidden email]>
>To: "Tony Mechelynck" <[hidden email]>
>Cc: <[hidden email]>
>Sent: Thursday, August 11, 2005 11:43 AM
>Subject: Re: How to open gvim on windows maximized....??
>
>
>> On Thu, 11 Aug 2005 10:40:33 +0200, "Tony Mechelynck"
>> <[hidden email]> wrote:
>>
>>>----- Original Message -----
>>>From: "J.C. Roberts" <[hidden email]>
>>>To: "Tony Mechelynck" <[hidden email]>
>>>Cc: <[hidden email]>
>>>Sent: Thursday, August 11, 2005 9:25 AM
>>>Subject: Re: How to open gvim on windows maximized....??
>>>
>>>
>>>> On Thu, 11 Aug 2005 08:54:49 +0200, "Tony Mechelynck"
>>>> <[hidden email]> wrote:
>>>>
>>>>>----- Original Message -----
>>>>>From: "J.C. Roberts" <[hidden email]>
>>>>>To: "Ankur Nayak" <[hidden email]>
>>>>>Cc: <[hidden email]>
>>>>>Sent: Thursday, August 11, 2005 8:23 AM
>>>>>Subject: Re: How to open gvim on windows maximized....??
>>>>>
>>>>>
>>>>>> On Wed, 10 Aug 2005 23:19:26 +0530, Ankur Nayak <[hidden email]>
>>>>>> wrote:
>>>>>>
>>>>>>>Hi,
>>>>>>>sorry if it is a trivial question. i searched the archives as well as
>>>>>>>the help but to no good results. Whenever I open gvim on windows it
>>>>>>>always opens in a small window and everytime i have to maxmize it
>>>>>>>manually. Is there any way by which I can open gvim in such a way that
>>>>>>>it opens as maximized.
>>>>>>>
>>>>>>>Thanks
>>>>>>>ankur
>>>>>>
>>>>>> The easiest solution has nothing to do with (re)programming the vim
>>>>>> startup. On MS-Windows, you have links (shortcuts) to your
>>>>>> applications. The location of the shortcut you see in your "Start
>>>>>> Button" menu, depends on the type of MS-Windows system you're running
>>>>>> and where/how vim was installed but in general, look for a directory
>>>>>> named "Start Menu"
>>>>>>
>>>>>> Right click on the vim shortcut, choose "Properties" go to the
>>>>>> "Shortcut" tab and look for the dropdown box named "Run" select
>>>>>> "Maximized" from the list, click Apply click OK.
>>>>>>
>>>>>> JCR
>>>>>
>>>>>Maybe the easiest, but certainly the least general, as it applies _only_
>>>>>to
>>>>>Vim sessions started by clicking on that particular shortcut, and not by
>>>>>any
>>>>>other means such as using the "Edit with Vim" menu item in the
>>>>>right-click
>>>>>context menu, typing gvim at the prompt in a Dos box, invoking gvim from
>>>>>a
>>>>>.BAT script, using gvim as auxiliary editor called from another
>>>>>application,
>>>>>or even by using a different shortcut, since you may have several, e.g.,
>>>>>one
>>>>>in the Start menu, one on the desktop, one in the Quick Launch toolbar,
>>>>>etc.
>>>>>OTOH anything in $HOME/_vimrc applies to any Vim session for that user,
>>>>>and
>>>>>anything in $VIM/vimrc applies to any Vim session for any user.
>>>>>
>>>>>Best regards,
>>>>>Tony.
>>>>>
>>>>
>>>> Tony,
>>>>
>>>> You definitely have a point about other startup methods but to be
>>>> fair, I really didn't want to go into all the various MS-Windows
>>>> hacking it would require to cover all methods.
>>>>
>>>> The MS-Windows "shortcut" is just a file with a (very) hidden
>>>> extension (*.lnk) and they are executable from the command line. All
>>>> arguments passed to the invoked shortcut will be passed to the
>>>> executable and work the same. It takes a bit of registry hacking to
>>>> reveal the shortcut extension but it is possible, even though it's
>>>> basically unnecessary.
>>>>
>>>> You can run the shortcut from the command line or in batch files or
>>>> where ever you like and you can copy it to the Quick Launch bar,
>>>> Desktop, start menu or anywhere. In other words, you've got something
>>>> that basically works like any other executable.
>>>>
>>>> Explorer extensions (i.e. file manager right click menu items) are
>>>> configurable through the registry. You can point the "Edit With Vim"
>>>> to use your modified shortcut and you get the desired affect.
>>>>
>>>> The only thing you can not do (without serious modification of the OS)
>>>> with a shortcuts is create a shortcut that points to another shortcut.
>>>>
>>>> Is it going to work on all MS-Windows start methods? -Yes.
>>>> Is it portable? -Nope.
>>>> Is hacking the vimrc easier? -Probably.
>>>> Is hacking up MS-Windows to work right a pain in the ass? -YES!
>>>>
>>>> You're basically right in theory since nobody really knows windows
>>>> internals anymore but in practice, you're technically wrong since it
>>>> is possible to do.
>>>>
>>>> "In theory there's no difference between practice and theory but in
>>>> practice there is."
>>>> --Yogi Beara
>>>>
>>>> :-)
>>>>
>>>> Kind Regards,
>>>> JCR
>>>
>>>You've got a strange conception of what is "theory" and what is
>>>"practice".
>>>I admit I may be "technically" wrong "in theory", but "in practice" the
>>>registry is esoteric, ill-documented, and proprietary to Micro$oft while
>>>the
>>>vimrc is well-documented, in plaintext, and reasonably cross-platform (and
>>>can be made really cross-platform, e.g. on dual-boot systems, by means of
>>>a
>>>few "if" statements). For this reason, I would not call setting up a vimrc
>>>"hacking" but if you can customize your registry in your sleep you might
>>>see
>>>matters differently. ;-)
>>>
>>>Best regards,
>>>Tony.
>>>
>>
>> I'm absolutely *certain* we can agree on the MS-registry being
>> esoteric, proprietary and poorly documented while vimrc is well
>> documented and cross platform. ;-)
>>
>> I took the liberty of hacking around in the registry with *.lnk files
>> to see what I could make of it. The process making them executable
>> from shell extensions is more convoluted that I remember.
>>
>> The easy method is to patch the gvimext.dll and gvim.exe. I've
>> disassembled the former and figured out how it's getting to the
>> CreateProcessA() call. From there it's a matter of figuring out the
>> StartupInfoA structure lives and modifying the dwFlags element...
>> Patching binaries is probably out of the question for normal users.
>>
>> Anyhow, at the moment vim uses the registry HKLM/Software/vim/gvim,
>> well, at least gvimext.dll does. It would not take much effort to set
>> things up such that on application load it checks the registry
>> HKLM/Software/vim/gvim for a "windowstate" value and on application
>> close, the current maximize/minimize status is saved to that value in
>> the registry. The result would be your window max/min would be based
>> on the "last use" of the application.
>>
>> JCR
>
>Except, again, for portability. You would have to do that in gvim, not
>gvimext, and there would be no corresponding mechanism for X11 or VMS.

Interesting. From what I saw inside gvimext.dll, it was very clearly a
MS-windows explorer shell extension and I didn't suspect it (well the
``gvimext'' name anyhow) was used for other OS's. To make it portable
and effective across all various ways the process is launched, the
save-state/load-state would need to be within the gvim executable.

>OTOH,
>it's child's play to write a little function to save the winposx, winposy,
>'lines' and 'columns' at the VimLeave event and restore them (if found) from
>the vimrc. I've seen it but haven't written it down; let's treat it as an
>exercise:
>

nice approach!

>    if has("gui_running")
>        function s:SaveWindow()
>            " function to be called at the VimLeave event
>            " create a vim script to be sourced at next startup
>            redir! > ~/winpos.vim
>            if &guifont != ""
>                silent echo "set guifont=" . escape(&guifont,' "\')
>            endif
>            if exists(":winpos") == 2
>                silent echo "winpos" getwinposx() getwinposy()
>            endif
>            silent echo "set lines=" . &lines "columns=" . &columns
>            redir END
>        endfunction
>        autocmd VimLeave * call s:SaveWindow()
>        " the argument to filereadable() must be a pathfilename
>        " in the proper format for the current OS, not in Vim format
>        if filereadable($HOME .
>            \ ((exists("+shellslash) && &noshellslash)?'\':'/') .
>            \ "winpos.vim")
>            source ~/winpos.vim
>        endif
>    endif
>
>Patching binaries is indeed probably out of question for most users,

In general, binary patching is considered "bad form" in the reverse
engineering world because the results are difficult (if not
impossible) to maintain over time. The only place bin-patching is
really used (and can be used without drawbacks) is in the embedded
world.

Disassembly should actually be the last resort and not a first choice
but in this case it was just a handy and fast way to look around and
see about changing trivial program internals on a particular platform.
Though a binary patch can be a fast answer to a problem, it's by no
means the best answer.


>but
>rather than patch the binaries, many programmers could (if they wanted to)
>patch the sources, at the expense (of course) of the risks which come with
>any branch in the code tree (and the added labour needed to port the
>bugfixes from the "main" tree again and again). Vim is open source,
>remember? and the sources of xxd.exe, gvimext.dll, vimrun.exe, install.exe
>and uninstal.exe are also there (I recompile them almost every night). No
>need to painstakingly disassemble. Anyway, given the choice, I'd rather add
>a few lines to my vimrc than patch the C sources (main.c probably). It's
>more general, more portable, and it doesn't run the risk of making the patch
>program choke 20 bugfixes later on too big an offset.
>
>Best regards,
>Tony.
>

I've just got to ask, how long have you been working on vim?
And which platforms do you run it on?

Your experience with vim shows ;-)

Between professional coding, testing and integration as well as doing
the very same thing as a hobby in open source, there's only so much
code/work a person can deal with and do. I didn't happen to have the
vim source on this particular system (NT4), so I just fired up my
disassembler (IDA Pro) to have a peek at things. Even if I had the
source and decided to code a solution, I seriously doubt my solution
would have been as elegant as yours.

In my book, you did things perfectly. You leveraged the existing
cross-platform scripting functionality to do what was needed rather
than trying to create additional functionality in the source that
would require platform specific conditions, testing and debugging.

Kind Regards,
JCR
Reply | Threaded
Open this post in threaded view
|

Re: How to open gvim on windows maximized....??

A.J.Mechelynck
----- Original Message -----
From: "J.C. Roberts" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 11, 2005 3:27 PM
Subject: Re: How to open gvim on windows maximized....??
[...]

> I've just got to ask, how long have you been working on vim?
> And which platforms do you run it on?

I forgot exactly how long. I thought it was just a year or two but Tim Chase
says he's seen my name in the vimlist archive dating back to 2002.

I first encountered Vim on Linux when I had a dual-boot desktop computer
(that must have been on SuSE 6 and RedHat 7 or so); then I found out it
worked also on Windows (98) and started using it there too, intead of
(bleerh!) Notepad, for all but the simplest editing tasks. On this laptop
(which I didn't choose but got as a present, and whose NTFS filesystem I
don't want to meddle with) I have only Windows (native and Cygwin) and I
feel motivated enough to compile Vim whenever I see a new 6.3 patch or a new
7.00 snapshot; from there it's not a big deal to upload the output of that
compile where everyone can get at it.
>
> Your experience with vim shows ;-)

Thanks for the compliment.

>
> Between professional coding, testing and integration as well as doing
> the very same thing as a hobby in open source, there's only so much
> code/work a person can deal with and do. I didn't happen to have the
> vim source on this particular system (NT4), so I just fired up my
> disassembler (IDA Pro) to have a peek at things. Even if I had the
> source and decided to code a solution, I seriously doubt my solution
> would have been as elegant as yours.
>
> In my book, you did things perfectly. You leveraged the existing
> cross-platform scripting functionality to do what was needed rather
> than trying to create additional functionality in the source that
> would require platform specific conditions, testing and debugging.
>
> Kind Regards,
> JCR

I used to be a professional programmer (in COBOL and assembly language)
starting in 1969 but after going back to college I found out one day that no
one was hiring EDP personnel without an EDP degree anymore, nor above 35
years of age. I did some freelance translation using PCs equipped with Dos
3, which allowed me to learn 8086 assembly language "in my spare time" and
write a few small utilities for myself. Nowadays the only language in which
I still program "seriously" is Vim script, and not on the scale on which
some other people do it: I have submitted to Vim-online a scriptlet to
switch "in orderly fashion" to Unicode and a few tips, one of which includes
a snippet of code to set the 'guifont' on any platform (GTK+2, kvim,
other-with-X11 and other), I'm the author of a (small) keymap for Esperanto
which is now distributed with Vim, and I have made "phonetic" keymaps for
Russian and Arabic which I feel aren't ready for public consumption yet.
Plus my vimrc of course. I'm also making some Dos .BAT scripts and (Cygwin)
bash scripts when I need them (and for instance the src/po/Make_cyg.mak to
generate the binary message translation files on Cygwin-based systems).
That's about all. Then the fact that I'm a (retired) junior-high-school
teacher shows in my "pedagogical" activity on this list -- and, as someone
recently said, "none of us is as smart as all of us": reading other people's
answers is a great way to learn.


Best regards,
Tony.