Resize windows inside screen.
[profile.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index 96f8a1f..98c3c52 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -214,12 +214,6 @@ endfun
 
 " Grow or shrink the window size.
 fun! Resize_Columns(op)
 
 " Grow or shrink the window size.
 fun! Resize_Columns(op)
-  " XXX: This won't work inside screen.
-  " We should really detect whether it would work rather than assume it won't.
-  if &term =~ '^screen'
-    return
-  endif
-
   " Vim 5 hardcodes the size of numbers column to 8.
   if version >= "700"
     let l:numberwidth = &numberwidth
   " Vim 5 hardcodes the size of numbers column to 8.
   if version >= "700"
     let l:numberwidth = &numberwidth
@@ -227,7 +221,20 @@ fun! Resize_Columns(op)
     let l:numberwidth = 8
   endif
 
     let l:numberwidth = 8
   endif
 
-  exec "se columns" . a:op . "=" . l:numberwidth
+  let l:resize = "se columns" . a:op . "=" . l:numberwidth
+
+  " HACK: Inside screen there is an extra line for the status bar.  Vim
+  " manages the resize by sending an escape sequence to set the number of
+  " lines and number of columns in one action.  To do this it will first query
+  " the number of lines and then set <same number of lines> by <new number of
+  " columns>.  Because of the extra line for the status bar this results in
+  " the real terminal being shrunk by a line.  We ask for the terminal to grow
+  " by a line so it ends up actually being the same.
+  if &term =~ '^screen'
+    let l:resize .= " lines+=1"
+  endif
+
+  exec l:resize
 endfun
 
 " Toggle number display.
 endfun
 
 " Toggle number display.