Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
3  
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. –  ldigas 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

8 Answers 8

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

gvim -geometry 1336x744
share|improve this answer

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: http://i.stack.imgur.com/2zmjC.png).

share|improve this answer

UPDATE: for linux users, I've found much better solution that really does maximize the window: http://stackoverflow.com/questions/12448179/how-to-maximize-vims-windows-on-startup-with-vimrc

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

endfunction

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 at 2:00

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 at 10:06

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
up vote 4 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 –  Walialu Jul 19 '12 at 7:14

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

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
2  
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
1  
~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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.