-
Notifications
You must be signed in to change notification settings - Fork 0
/
pjj_win_resize.vim
68 lines (52 loc) · 1.22 KB
/
pjj_win_resize.vim
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
" Vim global plugin that enables us to move status line with keys 'j' and 'k'.
" Maintainer: Atsushi SUGAWARA <peanutsjamjam@gmail.com>
" Last Change:2011 Feb 28
" License: This file is placed in the public domain.
"
" install to ~/.vim/plugin/
if &cp || exists("g:loaded_pjj_win_resize")
finish
endif
let g:loaded_pjj_win_resize = 1
let s:keepcpo = &cpo
set cpo&vim
let s:enabled = 0
function s:Enable()
if (winnr("$") == 1)
" there is only 1 window. byebye.
let s:enabled = 0
return
endif
if (winnr() != winnr("$"))
" not the last window
exe "nmap j <C-W>+"
exe "nmap k <C-W>-"
else
" here is the last (bottom) window
exe "nmap j <C-W>-"
exe "nmap k <C-W>+"
endif
exe "nmap h <C-W><"
exe "nmap l <C-W>>"
echo "Resize mode on. Press <C-W><C-E> again to quit."
endfunction
function s:Disable()
exe "nunmap j"
exe "nunmap k"
exe "nunmap h"
exe "nunmap l"
echo "Resize mode off."
endfunction
function! s:ToggleMode()
if s:enabled == 0
let s:enabled = 1
call s:Enable()
else
let s:enabled = 0
call s:Disable()
endif
endfunction
nnoremap <silent> <C-W><C-E> :call <SID>ToggleMode()<CR>
" vim: ts=2 sts=2 sw=2 et
let &cpo= s:keepcpo
unlet s:keepcpo