" 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
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.