From a43c8b2d1e426893e9a61a3e71315e8caeeb6ee2 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 17 Aug 2024 23:49:19 +0200 Subject: nvim: Create winmove for faster window/tab movement --- .config/nvim/plugin/winmove.vim | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .config/nvim/plugin/winmove.vim (limited to '.config/nvim/plugin') diff --git a/.config/nvim/plugin/winmove.vim b/.config/nvim/plugin/winmove.vim new file mode 100644 index 0000000..a72f6ab --- /dev/null +++ b/.config/nvim/plugin/winmove.vim @@ -0,0 +1,47 @@ +if &cp || exists('g:loaded_winmove') + finish +endif +let g:loaded_winmove = v:true + +function! winmove#Next() + let l:n1 = winnr() + wincmd l + if l:n1 != winnr() + return + endif + + tabnext + + let l:n1 = winnr() + while v:true + wincmd h + let l:n2 = winnr() + if l:n1 == l:n2 + return + endif + let l:n1 = l:n2 + endwhile +endfunction + +function! winmove#Prev() + let l:n1 = winnr() + wincmd h + if l:n1 != winnr() + return + endif + + tabprev + + let l:n1 = winnr() + while v:true + wincmd l + let l:n2 = winnr() + if l:n1 == l:n2 + return + endif + let l:n1 = l:n2 + endwhile +endfunction + +command! -nargs=0 WinMoveNext call winmove#Next() +command! -nargs=0 WinMovePrev call winmove#Prev() -- cgit v1.2.3