You can put this line:
autocmd GUIEnter * simalt ~x
at the end of your gvimrc
file.
This method uses the autocmd
feature to weave its magic. The command autocmd GUIEnter *
specifies a command to run after successfully starting the GUI for a file pattern of *
(any file).
The command it will execute, simalt ~x
(in Windows variants of vim
only), will simulate the keystroke Alt Spacebarx, which are the keystrokes that will maximise the window.
You can also use the shortened version:
au GUIEnter * sim ~x
but I prefer fully expanded commands myself, especially since it's the sort of thing you set and forget, only entering once when installing vim
onto a Windows system.
Keep in mind that this is simulating keystrokes in order to achieve its ends. On English versions, it will work fine since Alt-SpaceX is how you maximise a window.
If that doesn't work for you, you should investigate the keystrokes in whatever locale you're using. For example, the French version will use Agrandir
(enlarge) with the n
as the control keystroke, so the command you would need there is:
autocmd GUIEnter * simalt ~n
(which would actually minimise your window in English).
If you're some other (non-English, non-French) variant, just press Alt-Space on a window to bring up the system menu, and find out what key should be used (it should be underlined).
To find your gvimrc
file for adding whatever command you need, you can enter:
:version
:echo $VIM
:echo $HOME
and you should get a list of startup files and variables like:
system gvimrc file = "$VIM/gvimrc"
user gvimrc file = "$HOME/_gvimrc"
C:\Program Files (x86)\Vim
C:\Users\Pax\Documents