Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [O, ]O and cO map groups to change all windows #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions plugin/unimpaired.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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.'<C-R>=<SID>statusbump()<CR><CR>')
call s:map('n', ']o'.a:letter, ':'.a:mode.' no'.a:option.'<C-R>=<SID>statusbump()<CR><CR>')
call s:map('n', '=o'.a:letter, ':'.a:mode.' <C-R>=<SID>toggle("'.a:option.'")<CR><CR>')

exe s:map('n', '[O'.a:letter, ':call <SID>windo('''.a:mode.' '.a:option.''')<CR><C-R>=<SID>statusbump()<CR><CR>')
exe s:map('n', ']O'.a:letter, ':call <SID>windo('''.a:mode.' no'.a:option.''')<CR><C-R>=<SID>statusbump()<CR><CR>')
" NOTE: uses the value of the current window to toggle all.
exe s:map('n', '=O'.a:letter, ':call <SID>windo('''.a:mode.' <C-R>=<SID>toggle("'.a:option.'")<CR>'')<CR>')
endfunction

call s:map('n', '[ob', ':set background=light<CR>')
Expand Down