From dc8466b027ed44891a47251e71ff213f45de1e37 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Wed, 1 Feb 2023 22:54:09 +0000 Subject: add winswap.vim --- plugin/winswap.vim | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugin/winswap.vim (limited to 'plugin') diff --git a/plugin/winswap.vim b/plugin/winswap.vim new file mode 100644 index 0000000..739ba4d --- /dev/null +++ b/plugin/winswap.vim @@ -0,0 +1,28 @@ +function! s:do_window_swap() abort + let cur_buffer = bufnr('%') + let cur_win = win_getid() + + let expr = "" + let c = nr2char(getchar()) + while c =~ '[0-9]' + let expr = expr .. c + let c = nr2char(getchar()) + endwhile + let expr = expr .. c + + let w = winnr(expr) + if w > 0 + let wid = win_getid(w) + let buf = nvim_win_get_buf(wid) + + call nvim_win_set_buf(wid, cur_buffer) + call nvim_win_set_buf(cur_win, buf) + + exec w .. "wincmd w" + endif + +endfunction + +noremap (WindowSwap) call do_window_swap() +noremap (WindowSwap) +noremap (WindowSwap) -- cgit