Skip to content

Instantly share code, notes, and snippets.

@b0o
Last active August 20, 2021 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b0o/441152003be2dab037e4260af0520819 to your computer and use it in GitHub Desktop.
Save b0o/441152003be2dab037e4260af0520819 to your computer and use it in GitHub Desktop.
function! MoveWindow(dir)
let l:orig_win = winnr()
let l:orig_buf = bufnr()
exe 'wincmd ' . a:dir
let l:dest_win = winnr()
let l:dest_buf = bufnr()
exe l:orig_win . 'windo hide buf' l:dest_buf
exe l:dest_win . 'windo hide buf' l:orig_buf
endfunction
nnoremap <M-S-h> :call MoveWindow('h')<Cr>
nnoremap <M-S-j> :call MoveWindow('j')<Cr>
nnoremap <M-S-k> :call MoveWindow('k')<Cr>
nnoremap <M-S-l> :call MoveWindow('l')<Cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment