-
Notifications
You must be signed in to change notification settings - Fork 1
/
TWCommand.vim
57 lines (50 loc) · 1.32 KB
/
TWCommand.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
" File: plugin/TWCommand.vim
" Description: A plugin for moving & managing a tab or window.
" Author: yssl <http://github.com/yssl>
" License:
if exists("g:loaded_twcommand") || &cp
"finish
endif
let g:loaded_twcommand = 1
let s:keepcpo = &cpo
set cpo&vim
"""""""""""""""""""""""""""""""""""""""""""""
" global variable
if !exists('g:twcommand_restore_prevfocus')
let g:twcommand_restore_prevfocus = 1
endif
"if !exists('g:twcommand_prevtabnr')
"let g:twcommand_prevtabnr = tabpagenr()
"endif
"if !exists('g:twcommand_prevwinnr')
"let g:twcommand_prevwinnr = winnr()
"endif
if !exists('g:twcommand_maxhistory')
let g:twcommand_maxhistory = 10
"let g:twcommand_maxhistory = 5
endif
if !exists('g:twcommand_push')
let g:twcommand_push = 1
endif
" commands
command! -nargs=* TWCommand call TWCommand#TWCommand(<f-args>)
" autocmd
augroup TWCommandAutoCmds
autocmd!
"autocmd TabLeave * call s:OnTabLeave()
autocmd WinLeave * call s:OnWinLeave()
augroup END
" functions
"fun! s:OnTabLeave()
"let g:twcommand_prevtabnr = tabpagenr()
"endfun
fun! s:OnWinLeave()
"let g:twcommand_prevwinnr = winnr()
if g:twcommand_push
call TWCommand#PushHistory(tabpagenr(), winnr())
"echo 'winleave' tabpagenr() winnr()
endif
endfun
"""""""""""""""""""""""""""""""""""""""""""""
let &cpo= s:keepcpo
unlet s:keepcpo