Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to make gVim automatically maximize it's window when I open it? And a cross-plataform solution, I'm trying to use the same configs in a Linux and Windows machine...

I've tried the hack :set lines=999 columns=999, it almost works, but the window is not maximized, just resized and I lose some rows/columns.

share|improve this question
That's the most portable way I know. Could you elaborate on the "but the window is not maximized, just resized and I lose some rows/columns". Maximization is afaik, resizing till the edges. And I don't think I ever lost a row/col in that way. – Rook May 12 '10 at 19:04
@Idigas: correct, maximization is just "resize till it fills up available space (not covering toolbars etc)", in terms of wm-speak :) – akira May 13 '10 at 7:39
Setting the hack above doesn't resize till the edges. I'm starting to think the better approach is going to add an if in my vimrc: if it'd windows, call a config, else, call other config. – Somebody still uses you MS-DOS May 13 '10 at 12:15

From the Vim wiki:

au GUIEnter * simalt ~x

That'll work on Windows; I'm not sure what key combinations you'd need on Gnome/KDE.

share|improve this answer
This didn't work for me on Windows 7 Ultimate. – Matt Alexander Feb 18 '11 at 20:01
It also depends on the OS language sadly. For French Windows versions, it becomes au GUIEnter * simalt ~n. – ereOn Sep 7 '11 at 11:52
Is there a way to do the opposite, to un-maximize? Seems like :simalt ~x only works one way on Windows7x64 ENG. – TankorSmash Oct 17 '12 at 20:46
~x comes from keyboard shortcut for menu option. Check the shortcut for desire option and try it. Maybe it's Restore? – Grzegorz Gierlik Nov 3 '12 at 0:18
@GrzegorzGierlik Thanks, you're right. I didn't realize that simalt meant 'simulate the alt keypress'. Thanks. – TankorSmash Dec 8 '12 at 19:24
up vote 5 down vote accepted

The best way if you're concerned about cross-plataform is using :set lines=999 columns=999. I've found it in Vim's Wiki, wasn't so satisfied about it, buy if cross-plataform is a must, them this the solution.

share|improve this answer
Can you combine this with au GUIEnter * simalt ~x ?? – snitzr Jun 9 '10 at 1:34
Yes, creating a condition in your vimrc to know if it's windows or Linux. Since I'm mainly using Linux, I'm going to add this config later. – Somebody still uses you MS-DOS Jun 9 '10 at 12:22
This approach does not work for me under GNOME 3. When the window was already non-maximized, this will slow down Vim for a little while (does not happen when I maximize using the window manager), and it will leave a little edge above the window uncovered, because my screen height is not a perfect multiple of line height. When the window was vertically (but not horizontally) maximized by dragging the window to the left or right of the screen, this will have no effect. – Andres Riofrio May 2 '12 at 20:40
@AndresRiofrio For these situations (multiple desktop environments in Linux), I am seriously thinking about using devilspie. It's a third-party solution, I know, but it may work. I've used it in some other applications I wanted to be open maximized. – Somebody still uses you MS-DOS Jun 24 '12 at 1:56
Thanks, that did exactly what I want! <3 – Aloha Dakine Jul 19 '12 at 7:14

Trick with:

au GUIEnter * simalt ~x

depends on Windows language.

For my Polish version works:

au GUIEnter * simalt ~s

Where s comes from Mak_s_ymalizuj.

So if ~x doesn't work press ALT+SPACE to open Window menu and check shortcut for *Ma_x_imize Window* menu option.

share|improve this answer
And ~n for french ("Agra&ndir") – Sébastien RoccaSerra Jul 17 '13 at 14:16
And ~m for Norwegian – Bjarte Brandt Nov 21 '14 at 10:06

You can use maximize.dll plugin for fullscreen veiw on Vim (if you are using Windows). Just copy maximize.dll into vimdirectory/plugin folder.

share|improve this answer

For me, :simalt ~x did the trick. (Windows 7, English.)

share|improve this answer
Thanks, none of the other options worked on win7. – Chris Mar 14 '12 at 20:59

On GNU/Linux

On GNU/Linux, the easiest way is to invoke gvim with the -geometry option. For example:

gvim -geometry 1336x744

This is not handy if you would like to reuse the same start command on different machines.

Here is what I am using now on several machines without any issues. Just add it somewhere high up in your .vimrc.

if has("gui_running")
  " GUI is running or is about to start.
  " Maximize gvim window (for an alternative on Windows, see simalt below).
  set lines=999 columns=999
  " This is console Vim.
  if exists("+lines")
    set lines=50
  if exists("+columns")
    set columns=100


share|improve this answer
For linux this is probably the best option. in .zshrc do alias v="gvim -geometry 1366x768" and you're set for good. – Tanel Tammik Jan 30 at 17:16
@TanelTammik Have a look again at my answer. I have edited it substantially to show the better solution that I am using now. Thanks for up-voting. – Serge Stroobandt Jan 31 at 13:12

UPDATE: for linux users, I've found much better solution that really does maximize the window:

The only dependency is wmctrl, but it worths installing.

So, for windows I use maximize.dll plugin (as already mentioned by @fatihturan), and for linux I use wmctrl. Great!

(but I really can't understand why in 2014 gvim doesn't have this feature out-of-the-box)

Old answer:

For me, plain hack :set lines=999 columns=999 works badly on my Linux Mint MATE with two monitors. I have usually gvim opened on the secondary monitor, there're no taskbar, so, Vim should occupy the whole screen. But if I do :set lines=999 columns=999, gvim shrinks these values to the size of primary monitor, therefore, there are a small area below gvim window unused. It's better if I set real lines/columns count: just maximize your window "by hand" and type :set lines? and :set columns? , to get needed values. Since I use two monitors, I also need to specify window position, so, type :winpos to get current window position.

And secondary, it's better not just put these settings to the .vimrc, but execute them when gui is loaded.

So, final recipe:

1) maximize your gvim by hand and type three commands to get actual values: :winpos , :set lines? and :set columns? .

2) add this to .vimrc :

function Maximize()

   " put your actual values below
   winpos 0 0
   set lines=78
   set columns=237


autocmd GUIEnter * call Maximize()
share|improve this answer
Interesting. Maybe you can dinamically get the lines and columns values in vimscript, so this config will work in all devices. – Somebody still uses you MS-DOS Mar 20 '14 at 2:00

If you want your vim to achieve full screen in Windows thoroughly(like the picture), plugin gvimfullscreen_win32 1 is highly recommended.

By the plugin,you can achieve fullscreen better and be put into distractionrfreemode easyly. You can also add ":set go=" to gain more space. Here is a picture(Gvim7.4 on my windows8.1 Link:

share|improve this answer

I believe you can do this in your $HOME/.vimrc to achieve what you want:

if has("gui_running")
     set fuoptions=maxvert,maxhorz
     au GUIEnter * set fullscreen

You can confirm where the fullscreen is being applied like so:

:verbose set nofullscreen?
       Last set from ~/.vim_runtime/my_configs.vim
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .