vim-windowswap
vim-windowswap copied to clipboard
Support swapping windows in a given direction
I wrote a tiny function utilizing WindowSwap to swap two adjacent windows with a single mapping:
function! WindowSwapInDirection(dir)
call WindowSwap#MarkWindowSwap()
exec 'wincmd ' . a:dir
call WindowSwap#DoWindowSwap()
endfunction
noremap <silent> <M-S-h> :call WindowSwapInDirection('h')<cr>
noremap <silent> <M-S-j> :call WindowSwapInDirection('j')<cr>
noremap <silent> <M-S-k> :call WindowSwapInDirection('k')<cr>
noremap <silent> <M-S-l> :call WindowSwapInDirection('l')<cr>
This is super useful and I think it would be a nice addition to the WindowSwap plugin itself.
I don't have time to submit a PR right now but I thought I'd leave the snippet here in case anyone wants to do the same.
Exactly what I was looking for, thanks!