diff --git a/plugin/unimpaired.vim b/plugin/unimpaired.vim index 1a32d34..4032804 100644 --- a/plugin/unimpaired.vim +++ b/plugin/unimpaired.vim @@ -241,14 +241,28 @@ function! s:toggle(op) abort return eval('&'.a:op) ? 'no'.a:op : a:op endfunction -function! s:cursor_options() abort - return &cursorline && &cursorcolumn ? 'nocursorline nocursorcolumn' : 'cursorline cursorcolumn' +function! s:windo(command) + " By entering a window, its height is potentially increased from 0 to 1 (the + " minimum for the current window). To avoid any modification, save the + " window sizes and restore them after visiting all windows. + let winrestcmd = winrestcmd() + let currwin = winnr() + let prevwin = winnr('#') ? winnr('#') : 1 + execute 'windo '.a:command + execute prevwin.'wincmd w' + execute currwin.'wincmd w' + silent! execute winrestcmd endfunction function! s:option_map(letter, option, mode) abort call s:map('n', '[o'.a:letter, ':'.a:mode.' '.a:option.'=statusbump()') call s:map('n', ']o'.a:letter, ':'.a:mode.' no'.a:option.'=statusbump()') call s:map('n', '=o'.a:letter, ':'.a:mode.' =toggle("'.a:option.'")') + + exe s:map('n', '[O'.a:letter, ':call windo('''.a:mode.' '.a:option.''')=statusbump()') + exe s:map('n', ']O'.a:letter, ':call windo('''.a:mode.' no'.a:option.''')=statusbump()') + " NOTE: uses the value of the current window to toggle all. + exe s:map('n', '=O'.a:letter, ':call windo('''.a:mode.' =toggle("'.a:option.'")'')') endfunction call s:map('n', '[ob', ':set background=light')