sponsor Vim development Vim logo Vim Book Ad

windows_remember_size.vim : Expands the current window when focused to the size you last gave it.

 script karma  Rating 9/3, Downloaded by 1110  Comments, bugs, improvements  Vim wiki

created by
joey twiddle
script type
== New version: tries to automatically keep up without whatever layout changes
you make, by storing an unfocused and focused size for each window. ==

Explanation: Whenever you leave a window, it remembers what size it was, and
whenever you enter a window, it remembers what size it was before entering.
Thus it records "focused" and "unfocused" sizes for each window, and it will
try to grow/shrink windows on entering/leaving, to match the recorded value.

Note: This system is not perfect, specifically when adding a new window
(changing the layout) it makes no attempt to redistribute the space, so
other windows will act greedily until they are adjusted.

Solution: The best approach appears to be, as soon as your layout breaks in
some way, fix it immediately with 20<C-W>+ or whatever, to minimize the
damage (before the new broken values get recorded).  This is a small overhead
for the user, in exchange for the benefit gained with a fixed number of windows.

If you want to start afresh you can :call ForgetWindowSizes() and then Ctrl-=.


New feature: Set a default height for newly split windows, as percentage of
the size of the original window.  Without it Vim usually splits 50-50.

let g:wrs_default_height_pct = 90

We "detect" when a split is about to occur by mapping <Ctrl-W>s and :h
below.  You may want to add more mappings for other splitting actions.
install details
Drop in plugin/ folder

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
windows_remember_size.vim 4.0 2013-07-13 6.0 joey twiddle Added new feature wrs_default_height_pct.  Do try this out.  Gives 90% of Vim's height to the currently focused window.  (Adds a little complexity to what was a tiny script.)

Added :noautocmd to ForgetWindowSizes, to prevent lots of events from firing.

Removed older implementation attempts.  See v3.0 for curiosity.
windows_remember_size.vim 3.0 2013-06-26 6.0 joey twiddle Better compatibility with toggle_maximize.vim
windows_remember_size.vim 2.0 2012-10-24 6.0 joey twiddle Another alternative approach.
windows_remember_size.vim 1.0 2012-10-24 6.0 joey twiddle Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo