vim-windowswap icon indicating copy to clipboard operation
vim-windowswap copied to clipboard

Support swapping windows in a given direction

Open b0o opened this issue 3 years ago • 1 comments

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.

b0o avatar Apr 12 '21 01:04 b0o

Exactly what I was looking for, thanks!

piptouque avatar Oct 21 '22 12:10 piptouque