I\'m using the latest MacVim. Is there any way to have it so if I open MacVim without a file or with only one file, it sets the window width to n characters? Then if I do a
I realized that my first post modified window height, not width. Here is what I meant:
Here's a quick solution I came up with, but it's not perfect. The function counts the number of open windows and then sets the window width to original_width * num_windows
. The autocommands call the function when Vim starts, and whenever a new window is opened. You can change the default window width (80) to suit your needs.
function! SmartWidth( width )
let num_wins = 0
windo let num_wins+=1
sil exe "set columns=" . num_wins * a:width
sil exe "normal! \="
endfunction
autocmd VimEnter * call SmartWidth(80)
autocmd WinEnter * call SmartWidth(80)
This works in the basic case, but does not distinguish between horizontal and vertical splits. I don't know how to do that!