Skip to content

Instantly share code, notes, and snippets.

@mmisono
Created June 18, 2010 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmisono/443813 to your computer and use it in GitHub Desktop.
Save mmisono/443813 to your computer and use it in GitHub Desktop.
function! s:resizeWindow()
call submode#enter_with('winsize', 'n', '', 'mws', '<Nop>')
call submode#leave_with('winsize', 'n', '', '<Esc>')
let curwin = winnr()
wincmd j | let target1 = winnr() | exe curwin "wincmd w"
wincmd l | let target2 = winnr() | exe curwin "wincmd w"
execute printf("call submode#map ('winsize', 'n', 'r', 'j', '<C-w>%s')", curwin == target1 ? "-" : "+")
execute printf("call submode#map ('winsize', 'n', 'r', 'k', '<C-w>%s')", curwin == target1 ? "+" : "-")
execute printf("call submode#map ('winsize', 'n', 'r', 'h', '<C-w>%s')", curwin == target2 ? ">" : "<")
execute printf("call submode#map ('winsize', 'n', 'r', 'l', '<C-w>%s')", curwin == target2 ? "<" : ">")
endfunction
nmap <C-w>r :<C-u>call <SID>resizeWindow()<CR>mws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment