Created
June 16, 2010 15:45
-
-
Save mmisono/440872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" resize window | |
function! s:resizeWindow() | |
let mappings = [] | |
let curwin = winnr() | |
wincmd j | let target1 = winnr() | exe curwin "wincmd w" | |
wincmd l | let target2 = winnr() | exe curwin "wincmd w" | |
if curwin == target1 | |
call add(mappings,['j','-']) | call add(mappings,['k','+']) | |
else | |
call add(mappings,['j','+']) | call add(mappings,['k','-']) | |
endif | |
if curwin == target2 | |
call add(mappings,['h','>']) | call add(mappings,['l','<']) | |
else | |
call add(mappings,['h','<']) | call add(mappings,['l','>']) | |
endif | |
for i in mappings | |
execute printf('nnoremap <buffer> <silent> %s <C-w>%s:echo "window-resize"<CR>',i[0],i[1]) | |
endfor | |
nnoremap <buffer> <silent> = <C-w>=:echo "window-resize"<CR> | |
nnoremap <buffer> <silent> <C-g> :<C-u>call <SID>deleteMappings(['=','j','k','h','l','<C-g>'])<CR>:redraw!<CR> | |
echohl ModeMsg | |
echo "window-resize" | |
endfunction | |
function! s:deleteMappings(mappings) | |
for i in a:mappings | |
execute 'nunmap <buffer> ' . i | |
endfor | |
echohl None | |
endfunction | |
nnoremap <C-W>r :<C-u>call <SID>resizeWindow()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment