summaryrefslogtreecommitdiff
path: root/.config/nvim/plugin/winmove.vim
blob: a72f6ab308a334f29b4a9bf97772378280b1f065 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()