Restore screen size and position

This tip is useful if you always want Vim to startup in the same location and size as the time you exit it. Most applications (i.e. FireFox) do this already. Another reason to use this tip is if you often have more than one Vim (GUI on Windows) running. Quite often I will have one per project, each instance editing multiple buffers. When I start Vim, I name it (based on the project or tool I launched it from).

When I re-open Vim I like its screen position and size to be the same as they were when Vim was closed.
The scripts below can be added to your .vimrc file.
They offer 2 configuration options which can be set at the bottom before the autocmds:

" To enable the saving and restoring of screen positions.
let g:screen_size_restore_pos = 1
" To save and restore screen for each Vim instance.
" This is useful if you routinely run more than one Vim instance.
" For all Vim to use the same settings, change this to 0.
let g:screen_size_by_vim_instance = 1

This version uses Vim's readfile() and writefile() functions to access the file used to save the size/position. That in addition to the use of the split() function makes this version unusable in Vim 6.x.

For the Version 2 script, since it uses Vim buffers for the manipulations it would be useful to disable all autocmds before opening splitting the buffer and re-enable them when closing the buffer. Many people have lots of plugins installed which can make opening buffers somewhat expensive (and therefore unnecessary time delay). Using the Vim 7 readfile() and writefile() functions avoid this overhead.