21

I would like to start gvim, from the command line, into a maximized window - how can I do this?

I have no wish to always start in a maximized window (that is, not configure it as default in .vimrc), but rather choose to provide a parameter to the program.

That is, running gvim <parameter(s)> should start the program in a maximized window but just running gvim should start the program with the default size.

1

7 Answers 7

17

Just like many other Gtk+ apps, gvim understands the parameter -geometry. Try for example

gvim -geometry 500x500
0
16

For me (I'm on Ubuntu 11.10), adding this to my .vimrc seems to do the trick. No need for geometry settings, etc.

if has("gui_running")
  " GUI is running or is about to start.
  " Maximize gvim window.
  set lines=999 columns=999
endif
3
  • 1
    works nice in gvim (Ubuntu 12.10). No need for vimrc, the one can change gvim.desktop and add in TryExec param --cmd "set lines=100 columns=200" . That way you can configure gvim shortcuts individually. Higher values made gvim appear on other desktop.
    – majkinetor
    Dec 9, 2012 at 20:11
  • 1
    Actually, if you change font size, u need to change lines/cols again if you dont want to appear on other desktop
    – majkinetor
    Dec 11, 2012 at 15:39
  • this cause warnings on my ubuntu 13.10.
    – squid
    Jan 7, 2014 at 6:40
11

You should be able to change the size by going into the vimrc file, where you can specify the size or maximize it on open.

Have a look here.

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

1
  • 7
    From the question: "(that is, not configure it as default in .vimrc)", from the answer "change the size by going into the vimrc file". Please read the question carefully.
    – DrAl
    Jan 18, 2011 at 11:14
7

On Windows 7 I have this in my _vimrc:

" Run maximized in diff mode
if &diff 
   au GUIEnter * simalt ~x
else
   set lines=55 columns=130
endif

So when I run Vim in diff mode (e.g. from TortoiseSVN), Vim starts maximized.

Similarly, it can be changed to:

" Run maximized in GUI
if has("gui_running")
   au GUIEnter * simalt ~x
endif
5

Put to .vimrc

" Maximize GVim on start
if has("gui_running")
  set lines=999 columns=999
endif

stolen from: http://vim.wikia.com/wiki/Maximize_or_set_initial_window_size

1
3

On Windows you can try add following to your _vimrc

au GUIEnter * simalt ~x

Note that ~x comes from keyboard shortcut for menu option, it might vary on different OS language. So check the shortcut for desire option and try it.

3

On Linux I use this in my .vimrc:

augroup maximizewindow 
    autocmd! 
    autocmd VimEnter * call system('wmctrl -i -b add,maximized_vert,maximized_horz -r '.v:windowid)
augroup END

This auto command will trigger after the VimEnter event has been triggered. When that happens it runs wmctrl on the current window to maximize it.

This requires that you have wmctrl installed.

1
  • works like a charm, had some error with my previous config set lines=999 columns=999 with bigger resolution: (gvim:25777): Gdk-WARNING **: 20:57:09.043: Native Windows wider or taller than 32767 pixels are not supported Now solved with: autocmd VimEnter * call system('wmctrl -i -b add,maximized_vert,maximized_horz -r '.v:windowid)
    – chloesoe
    Mar 29 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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