From 5f647427f7b00bd2d5c3d5a2f91cb906db7ef32c Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 25 Jan 2010 10:55:31 +0000 Subject: [PATCH] Restore window height when leaving Vim. --- .vimrc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.vimrc b/.vimrc index ad3a73a..398e981 100644 --- a/.vimrc +++ b/.vimrc @@ -129,10 +129,13 @@ augroup StatusLine autocmd! augroup END -" Save the current window width so we can restore it when we quit. +" Save the current window dimensions so we can restore them when we quit. if ! exists("g:oldcols") let g:oldcols=&columns endif +if ! exists("g:oldlines") + let g:oldlines=&lines +endif " More GUI options. Add icon and tearoffs. se go+=i @@ -302,7 +305,7 @@ fun! Can_Resize() "{{{2 return g:resizable endfun "}}}2 -" Grow or shrink the window size. +" Grow or shrink the window width. fun! Resize_Columns(op, ...) "{{{2 if a:op == "" return @@ -340,6 +343,25 @@ fun! Resize_Columns(op, ...) "{{{2 exe l:resize endfun "}}}2 +" Grow or shrink the window height. +fun! Resize_Lines(op, lines) "{{{2 + if a:op == "" + return + endif + + if ! Can_Resize() + return + endif + + exe "let l:resize=" . &lines . a:op . a:lines + if &term =~ '^screen' + let l:resize = l:resize + 1 + endif + let l:resize = "se lines=" . l:resize + + exe l:resize +endfun "}}}2 + " Set extra columns depending on window status. fun! Extra_Columns(extra, var, ...) "{{{2 " Vim 6 doesn't have winnr("$"). Determine which windows are open @@ -413,6 +435,7 @@ endfun "}}}2 " Restore window size. if ! has("gui_running") au Display VimLeave * if exists("g:oldcols") | call Resize_Columns("-", (&columns - g:oldcols)) | endif + au Display VimLeave * if exists("g:oldlines") | call Resize_Lines("-", (&lines - g:oldlines)) | endif endif " Map Makefile mode. -- 2.7.4