I wanted vim to increase its &columns
automatically when I do a :vsplit
, so I implemented the advice found here: https://groups.google.com/forum/#!topic/vim_use/R4gg-YdPHJM
Basically, you add:
autocmd WinEnter * if winwidth(0) < 80 | set columns+=80 | wincmd = | endif
to .vimrc
.
However, in terminal vim, I opened 3 windows side-by-side, and the &columns
increased beyond the size of my terminal.
I tried to do this:
if &columns + 79 > $COLUMNS | set columns=$COLUMNS | else | set columns+=79 | endif
but it didn't work, saying, "Number required after =: columns=$COLUMNS
".
How can I get &columns
to increase but only up to a maximum of the $COLUMNS
environment variable?