events - Automatically resize vim gui according to number of vertical splits -


i writing small plugin gvim automatically increases or decreases width of gui according number of vertical splits. plugin works this

if has("gui_running")   augroup resize     autocmd winenter * call <sid>resizesplits()     autocmd winleave * call <sid>resizesplits()     autocmd bufleave * call <sid>resizesplits()   augroup end endif 

here resizesplits() function resizes gui window:

function! s:resizesplits()   let l:count = 0   windo   if winwidth(winnr()) < &columns |          \   let l:count += 1              |         \ endif   if l:count > 0     let l:totwidth = l:count - 1 + l:count*80   else     let l:totwidth = 80   endif   if &columns != l:totwidth     execute 'set co=' . l:totwidth   endif endfunction 

the plugin works want to, not quite. seems bufleave event (and similar ones) executes before windows closed. problem instance when <c-w>o or :only. problem resizesplits function not work, since still counts old number of windows.

is there autocommand can used detect when number of windows has been changed, or bufleave-like event guaranteed executed after windows destroyed/removed?

it trivial plugin work mappings, not able work reliably ex commands :only , :close.

there's no exact event :close / :quit; closest bufwinleave, doesn't fire when buffer still visible in buffer. combine bufleave, have check buffer not visible more.

to handle unlisted buffers, can add condition checking 'buflisted' in executed autocmd.

edit after update of question

i don't think there's way intercept corner cases you've described. :only tricky. can propose work around additional autocmds on cursorhold , cursormoved. way, incorrect state persist short time.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -