Is it possible to get gVim to remember window size?

戏子无情 提交于 2019-12-02 18:50:20

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.

Andrej Mitrović

These lines save and restore just the position and size:

set sessionoptions+=resize,winpos
autocmd VIMEnter * :source C:/session.vim
autocmd VIMLeave * :mksession! C:/session.vim
thegreatvalley

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!

Jeremy Sharpe

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

see :h ssop

gvim -geom 85x55

as in, putting this in your .bashrc:

alias G='gvim -geom 85x55'

If you just want vim to open to the same size every time, you can edit your user's vimrc in C:/Users/<yourUserName>/_vimrc (this is preferred to editing the system _vimrc in your vim installation folder) to include the line set lines=<yourHeight> columns=<yourWidth>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!