tags:

views:

1211

answers:

4

I know how to set the initial window size in gVim, but how do I get it to automatically restore the window dimensions from last session? Is this even possible?

+9  A: 

Edit: Corrected my answer. The mentioned winsize sessionoption only refers to the vim internal window layout, not the external dimensions.


If you use

:mksession

and load the session on vim startup with

gvim -S Session.vim

you can include the window position and size into the session by including winpos and resize in the sessionoptions, see

:help  'sessionoptions

With autocommands you could even automate the saving and restoring of the session on Vim entry and exit.

Thanks for the answer! I'm still quite new to Vim, so I'm not terribly experienced with autocommands. How would I get them to fire on entry and exit?
Charles Roper
See :help autocommand, especially the GUIEnter, VIMEnter, VIMLeave events look promising.
A: 
gvim -geom 85x55

as in, putting this in your .bashrc:

alias G='gvim -geom 85x55'
kajaco
+2  A: 

I had the same question, and to expand on the above answer, you can simply add the following to your .vimrc to get the behaviour you want:

set sessionoptions+=resize,winpos

Smug Duckling
A: 

Additionally:

In your .vimrc: set ssop+=resize,winpos,winsize,blank,buffers,curdir,folds,help,options,tabpages

Then, use the script from this article, it works beautifully! http://broom9.com/Vim_Tips_Wiki/index.php?title=Restore_screen_size_and_position

thegreatvalley