1 " Copyright: Copyright (C) 2005 Marius Groleo
2 " Permission is hereby granted to use and distribute this code,
3 " with or without modifications, provided that this copyright
4 " notice is copied with it. Like anything else that's free,
5 " tabbar.vim is provided *AS IS* and comes with no warranty of
6 " any kind, either expressed or implied. In no event will the
7 " copyright holder be liable for any damamges resulting from the
8 " use of this software.
10 " Derived from Bindu Wavell miniBufExplorer.vim version 6.3.2
14 " Maintainer: Marius Groleo < groleo@gmail.com >
15 " Description: TabBar buffer explorer Vim Plugin
16 " Name Of File: tabbar.vim
18 " DOCUMENTATION: is at line :1445
20 " press zR , in normal mode to OPEN all folds
21 " press zM , in normal mode to CLOSE all folds
23 " Already been loaded? ~~
24 if exists('Tb_loaded')
33 " 1-5 = errors ; 1 is the most important
34 " 5-9 = info ; 5 is the most important
36 if !exists('g:Tb_DBG_LVL')
43 " 1 = log with vim's echo facility
44 " 2 = log to a file named TabBar.DBG
45 " in the directory where vim was started
47 " 3 = log into g:Tb_DbgOutput
48 " global variable [This is the default]
49 if !exists('g:Tb_DebugMode')
50 let g:Tb_DebugMode = 0
54 " Mappings and Commands
55 " TabBar Keyboard Mappings ~~
56 if ! hasmapto('
\e1') || !hasmapto('<M-1>')
57 "gui bindings containing META key, are different from terminal bindings
59 "NORMAL mode bindings for gvim
60 noremap <unique> <script> <M-1> :call <SID>Bf_SwitchTo( 1)<CR>:<BS>
61 noremap <unique> <script> <M-2> :call <SID>Bf_SwitchTo( 2)<CR>:<BS>
62 noremap <unique> <script> <M-3> :call <SID>Bf_SwitchTo( 3)<CR>:<BS>
63 noremap <unique> <script> <M-4> :call <SID>Bf_SwitchTo( 4)<CR>:<BS>
64 noremap <unique> <script> <M-5> :call <SID>Bf_SwitchTo( 5)<CR>:<BS>
65 noremap <unique> <script> <M-6> :call <SID>Bf_SwitchTo( 6)<CR>:<BS>
66 noremap <unique> <script> <M-7> :call <SID>Bf_SwitchTo( 7)<CR>:<BS>
67 noremap <unique> <script> <M-8> :call <SID>Bf_SwitchTo( 8)<CR>:<BS>
68 noremap <unique> <script> <M-9> :call <SID>Bf_SwitchTo( 9)<CR>:<BS>
69 noremap <unique> <script> <M-0> :call <SID>Bf_SwitchTo( 10)<CR>:<BS>
70 "INSERT mode bindings for gvim
71 inoremap <unique> <script> <M-1> <esc>:call <SID>Bf_SwitchTo( 1)<CR>:<BS>a
72 inoremap <unique> <script> <M-2> <esc>:call <SID>Bf_SwitchTo( 2)<CR>:<BS>a
73 inoremap <unique> <script> <M-3> <esc>:call <SID>Bf_SwitchTo( 3)<CR>:<BS>a
74 inoremap <unique> <script> <M-4> <esc>:call <SID>Bf_SwitchTo( 4)<CR>:<BS>a
75 inoremap <unique> <script> <M-5> <esc>:call <SID>Bf_SwitchTo( 5)<CR>:<BS>a
76 inoremap <unique> <script> <M-6> <esc>:call <SID>Bf_SwitchTo( 6)<CR>:<BS>a
77 inoremap <unique> <script> <M-7> <esc>:call <SID>Bf_SwitchTo( 7)<CR>:<BS>a
78 inoremap <unique> <script> <M-8> <esc>:call <SID>Bf_SwitchTo( 8)<CR>:<BS>a
79 inoremap <unique> <script> <M-9> <esc>:call <SID>Bf_SwitchTo( 9)<CR>:<BS>a
80 inoremap <unique> <script> <M-0> <esc>:call <SID>Bf_SwitchTo( 10)<CR>:<BS>a
82 "NORMAL mode bindings for vim( dos32 )
83 noremap <unique> <script> ± :call <SID>Bf_SwitchTo( 1)<CR>:<BS>
84 noremap <unique> <script> ² :call <SID>Bf_SwitchTo( 2)<CR>:<BS>
85 noremap <unique> <script> ³ :call <SID>Bf_SwitchTo( 3)<CR>:<BS>
86 noremap <unique> <script> ´ :call <SID>Bf_SwitchTo( 4)<CR>:<BS>
87 noremap <unique> <script> µ :call <SID>Bf_SwitchTo( 5)<CR>:<BS>
88 noremap <unique> <script> ¶ :call <SID>Bf_SwitchTo( 6)<CR>:<BS>
89 noremap <unique> <script> · :call <SID>Bf_SwitchTo( 7)<CR>:<BS>
90 noremap <unique> <script> ¸ :call <SID>Bf_SwitchTo( 8)<CR>:<BS>
92 "NORMAL mode bindings for vim( terminal)
93 noremap <unique> <script>
\e1 :call <SID>Bf_SwitchTo( 1)<CR>:<BS>
94 noremap <unique> <script>
\e2 :call <SID>Bf_SwitchTo( 2)<CR>:<BS>
95 noremap <unique> <script>
\e3 :call <SID>Bf_SwitchTo( 3)<CR>:<BS>
96 noremap <unique> <script>
\e4 :call <SID>Bf_SwitchTo( 4)<CR>:<BS>
97 noremap <unique> <script>
\e5 :call <SID>Bf_SwitchTo( 5)<CR>:<BS>
98 noremap <unique> <script>
\e6 :call <SID>Bf_SwitchTo( 6)<CR>:<BS>
99 noremap <unique> <script>
\e7 :call <SID>Bf_SwitchTo( 7)<CR>:<BS>
100 noremap <unique> <script>
\e8 :call <SID>Bf_SwitchTo( 8)<CR>:<BS>
101 noremap <unique> <script>
\e9 :call <SID>Bf_SwitchTo( 9)<CR>:<BS>
102 noremap <unique> <script>
\e0 :call <SID>Bf_SwitchTo( 10)<CR>:<BS>
103 "INSERT mode bindings for vim( terminal)
104 inoremap <unique> <script>
\e1 <esc>:call <SID>Bf_SwitchTo( 1)<CR>:<BS>a
105 inoremap <unique> <script>
\e2 <esc>:call <SID>Bf_SwitchTo( 2)<CR>:<BS>a
106 inoremap <unique> <script>
\e3 <esc>:call <SID>Bf_SwitchTo( 3)<CR>:<BS>a
107 inoremap <unique> <script>
\e4 <esc>:call <SID>Bf_SwitchTo( 4)<CR>:<BS>a
108 inoremap <unique> <script>
\e5 <esc>:call <SID>Bf_SwitchTo( 5)<CR>:<BS>a
109 inoremap <unique> <script>
\e6 <esc>:call <SID>Bf_SwitchTo( 6)<CR>:<BS>a
110 inoremap <unique> <script>
\e7 <esc>:call <SID>Bf_SwitchTo( 7)<CR>:<BS>a
111 inoremap <unique> <script>
\e8 <esc>:call <SID>Bf_SwitchTo( 8)<CR>:<BS>a
112 inoremap <unique> <script>
\e9 <esc>:call <SID>Bf_SwitchTo( 9)<CR>:<BS>a
113 inoremap <unique> <script>
\e0 <esc>:call <SID>Bf_SwitchTo( 10)<CR>:<BS>a
118 " TabBar <Script> internal map ~~
119 noremap <unique> <script> <Plug>tbstart :call <SID>Tb_Start(1, -1)<CR>:<BS>
120 noremap <unique> <script> <Plug>tbstop :call <SID>Tb_Stop(1)<CR>:<BS>
121 noremap <unique> <script> <Plug>tbaut :call <SID>Tb_Aup(-1)<CR>:<BS>
122 noremap <unique> <script> <Plug>tbtoggle :call <SID>Tb_Toggle()<CR>:<BS>
127 if !exists(':TbStart')
128 command! TbStart call <SID>Tb_Start(1, -1)
131 if !exists(':TbStop')
132 command! TbStop call <SID>Tb_Stop(1)
136 command! TbAup call <SID>Tb_AutoUpdt(-1)
139 if !exists(':TbToggle')
140 command! TbToggle call <SID>Tb_Toggle()
144 command! Tbbn call <SID>Bf_Cycle(1)
147 command! Tbbp call <SID>Bf_Cycle(0)
152 " Global Configuration Variables
153 " Allow auto update? ~~
154 " We start out with this off for startup, but once vim is running we
156 if !exists('g:Tb_AutoUpdt')
157 let g:Tb_AutoUpdt = 0
162 " Display Mini Buf Explorer when there are 'More Than One' eligible buffers
163 if !exists('g:Tb_MoreThanOne')
164 let g:Tb_MoreThanOne = 2
168 " Split below/above/left/right? ~~
169 " When opening a new -TabBar- window, split the new windows below or
170 " above the current window? 1 = below, 0 = above.
171 if !exists('g:Tb_SplitBelow')
172 let g:Tb_SplitBelow = &splitbelow
176 " Horizontal or Vertical explorer? ~~
177 " For folks that like vertical explorers, I'm caving in and providing for
178 " veritcal splits. If this is set to 0 then the current horizontal
179 " splitting logic will be run. If however you want a vertical split,
180 " assign the width (in characters) you wish to assign to the -TabBar- window.
181 if !exists('g:Tb_VSplit')
187 " By default line wrap is used (possibly breaking a tab name between two
188 " lines.) Turning this option on (setting it to 1) can take more screen
189 " space, but will make sure that each tab is on one and only one line.
190 if !exists('g:Tb_TabWrap')
195 " Switch buffers using Ctrl-Tab ?~~
196 if !exists('g:Tb_cTabSwitchBufs')
197 let g:Tb_cTabSwitchBufs = 1
201 " if cTabSwitchBufs is turned on then we turn off cTabSwitchWindows.~~
202 if g:Tb_cTabSwitchBufs == 1 || !exists('g:Tb_cTabSwitchWindows')
203 let g:Tb_cTabSwitchWindows = 0
207 " If we have enabled <C-TAB> and <C-S-TAB> to switch buffers~~
208 " in the current window then perform the remapping
209 if g:Tb_cTabSwitchBufs
210 noremap <C-TAB> :call <SID>Bf_Cycle(1)<CR>:<BS>
211 noremap <C-S-TAB> :call <SID>Bf_Cycle(0)<CR>:<BS>
215 " If we have enabled <C-TAB> and <C-S-TAB> to switch windows ~~
216 " then perform the remapping
217 if g:Tb_cTabSwitchWindows
218 noremap <C-TAB> <C-W>w
219 noremap <C-S-TAB> <C-W>W
223 " Modifiable Select Target ~~
224 if !exists('g:Tb_ModSelTarget')
225 let g:Tb_ModSelTarget = 0
229 " Force Syntax Enable ~~
230 if !exists('g:Tb_ForceSyntaxEnable')
231 let g:Tb_ForceSyntaxEnable = 0
235 " Single/Double Click? ~~
236 " flag that can be set to 1 in a users .vimrc to allow
237 " single click switching of tabs. By default we use
238 " double click for tab selection.
239 if !exists('g:Tb_UseSingleClick')
240 let g:Tb_UseSingleClick = 0
244 " attempt to perform single click mapping, it would be much
245 " nicer if we could nnoremap <buffer> ... however vim does
246 " not fire the <buffer> <leftmouse> when you use the mouse
249 if g:Tb_UseSingleClick == 1
250 let s:clickmap = ':if bufname("%") == "-TabBar-" <bar> call <SID>Tb_Click() <bar> endif <CR>'
251 if maparg('<LEFTMOUSE>', 'n') == ''
252 " no mapping for leftmouse
253 exec ':nnoremap <silent> <LEFTMOUSE> <LEFTMOUSE>' . s:clickmap
256 let g:Tb_DoneClickSave = 1
257 let s:m = ':nnoremap <silent> <LEFTMOUSE> <LEFTMOUSE>'
258 let s:m = s:m . substitute(substitute(maparg('<LEFTMOUSE>', 'n'), '|', '<bar>', 'g'), '\c^<LEFTMOUSE>', '', '')
259 let s:m = s:m . s:clickmap
269 " used to pass maxTabWidth info between functions
270 let s:maxTabWidth = 0
277 " Global used to store the buffer list so we don't update the ~~
278 " UI unless the list has changed.
279 if !exists('g:Tb_VimBufList')
280 let g:Tb_VimBufList = ''
281 let g:Tb_BufferMap=''
285 " g:Tb_UpdtMutex: Variable used as a mutex so that we don't do lots~~
286 " of Tb_AutoUpdts at the same time.
287 if !exists('g:Tb_UpdtMutex')
288 let g:Tb_UpdtMutex = 0
292 " g:Tb_MaxHeight maxSize ~~
293 if !exists('g:Tb_MaxSize')
295 "TODO implement Tb_MaxHeight
299 " g:Tb_MaxHeight MinSize ~~
300 if !exists('g:Tb_MinSize')
302 "TODO implement Tb_MaxHeight
306 " g:Tb_DbgOutput: In debug mode 3 this variable will hold the debug output~~
307 if !exists('g:Tb_DbgOutput')
308 let g:Tb_DbgOutput = ''
312 " g:Tb_ForceDisplay ~~
313 if !exists('g:Tb_ForceDisplay')
314 let g:Tb_ForceDisplay = 0
318 " Setup an autocommand group and some autocommands ~~
319 " that keep our explorer updated automatically.
321 autocmd TabBar BufDelete * call <SID>DEBUG('-=> BufDelete AutoCmd', 10) |call <SID>Tb_AutoUpdt(expand('<abuf>'))
322 autocmd TabBar BufEnter * call <SID>DEBUG('-=> BufEnter AutoCmd', 10) |call <SID>Tb_AutoUpdt(-1)
323 autocmd TabBar VimEnter * call <SID>DEBUG('-=> VimEnter AutoCmd', 10) |let g:Tb_AutoUpdt = 1 |call <SID>Tb_AutoUpdt(-1)
330 " Tb_Start - Sets up our explorer and causes it to be displayed ~~
331 function! <SID>Tb_Start(sticky, delBufNum)
333 call <SID>DEBUG('ENTER: Tb_Start()' ,10)
337 let g:Tb_AutoUpdt = 1
340 " Store the current buffer
341 let l:curBuf = bufnr('%')
343 " Prevent a report of our actions from showing up.
344 let l:save_rep = &report
345 let l:save_sc = &showcmd
349 call <SID>Win_FindOrCreate('-TabBar-', -1, 1)
351 " Make sure we are in our window
352 if bufname('%') != '-TabBar-'
353 call <SID>DEBUG('Tb_Start: called in invalid window',1)
354 let &report = l:save_rep
355 let &showcmd = l:save_sc
359 " !!! We may want to make the following optional -- Bindu
360 " New windows don't cause all windows to be resized to equal sizes
362 " !!! We may want to make the following optional -- Bindu
363 " We don't want the mouse to change focus without a click
366 " If folks turn numbering and columns on by default we will turn
367 " them off for the -TabBar- window
368 setlocal foldcolumn=0
373 syn match Tb_Normal '\[[^\]]*\]'
374 syn match Tb_Changed '\[[^\]]*\]+'
375 syn match Tb_VisibleNormal '\[[^\]]*\]\*+\='
376 syn match Tb_VisibleChanged '\[[^\]]*\]\*+'
378 if !exists("g:did_tabbar_syntax_inits")
379 let g:did_tabbar_syntax_inits = 1
380 highlight def link Tb_Normal Comment
381 highlight def link Tb_Changed String
382 highlight def link Tb_VisibleNormal StatusLineNC
383 highlight def link Tb_VisibleChanged Special
388 " If you press return in the -TabBar- then try
389 " to open the selected buffer in the previous window.
390 " Bf_CrSel = Buffer CR Select
391 nnoremap <buffer> <CR> :call <SID>Bf_CrSel()<CR>:<BS>
394 " If you Bf_DblClkSel in the -TabBar- then try
395 " to open the selected buffer in the previous window.
396 nnoremap <buffer> <2-LEFTMOUSE> :call <SID>Bf_DblClkSel()<CR>:<BS>
399 " delete the selected buffer.
400 nnoremap <buffer> d :call <SID>Bf_DelWithD()<CR>:<BS>
403 " If you press w in the -TabBar- then switch back
404 " to the previous window.
405 nnoremap <buffer> p :wincmd p<CR>:<BS>
407 " The following allows for quicker moving between buffer
408 " names in the -TabBar- window it also saves the last-pattern
410 nnoremap <buffer> <TAB> :call search('\[[0-9]*:[^\]]*\]')<CR>:<BS>
411 nnoremap <buffer> <S-TAB> :call search('\[[0-9]*:[^\]]*\]','b')<CR>:<BS>
413 call <SID>Bf_SafePrint(a:delBufNum)
416 call search('\['.l:curBuf.':'.expand('#'.l:curBuf.':t').'\]')
418 call <SID>DEBUG('Tb_Start: No current buffer to search for',9)
421 let &report = l:save_rep
422 let &showcmd = l:save_sc
425 call <SID>DEBUG('EXIT : Tb_Start()' ,10)
430 " Tb_Stop - Looks for our explorer and closes the window if it is opened ~~
431 function! <SID>Tb_Stop( sticky)
433 call <SID>DEBUG('ENTER: Tb_Stop()' ,10)
437 let g:Tb_AutoUpdt = 0
440 let l:winNum = <SID>Win_Find('-TabBar-')
443 exec l:winNum.' wincmd w'
449 call <SID>DEBUG('EXIT : Tb_Stop()' ,10)
454 " Tb_Toggle - Looks for our explorer and opens/closes the window ~~
455 function! <SID>Tb_Toggle()
457 call <SID>DEBUG('ENTER: Tb_Toggle()' ,10)
460 let g:Tb_AutoUpdt = 0
462 let l:winNum = <SID>Win_Find('-TabBar-')
467 call <SID>Tb_Start(1, -1)
472 call <SID>DEBUG('EXIT : Tb_Toggle()' ,10)
477 " Tb_Max - Returns the max of two numbers ~~
478 function! <SID>Tb_Max(argOne, argTwo)
479 if a:argOne > a:argTwo
487 " Tb_AutoUpdt - Function called by auto commands for auto updating -TabBar- ~~
488 " IF auto update is turned on AND
489 " we are in a real buffer AND
490 " we have enough eligible buffers THEN
491 " Update our explorer and get back to the current window
492 " If we get a buffer number for a buffer that
493 " is being deleted, we need to make sure and
494 " remove the buffer from the list of eligible
495 " buffers in case we are down to one eligible
496 " buffer, in which case we will want to close
497 " the -TabBar- window.
498 function! <SID>Tb_AutoUpdt(delBufNum)
500 call <SID>DEBUG('ENTER: Tb_AutoUpdt( delBufNum='.a:delBufNum.') : bufnr(%)='.bufnr('%').' : bufname(%)=['.bufname('%') . ']',10)
503 if (g:Tb_UpdtMutex == 1)
505 call <SID>DEBUG('Tb_AutoUpdt: recursion stopped',9)
506 call <SID>DEBUG('EXIT : Tb_AutoUpdt()' ,10)
510 let g:Tb_UpdtMutex = 1
513 " Don't update the TabBar window
514 if (bufname('%') == '-TabBar-')
515 " If this is the only buffer left then toggle the buffer
516 if (winbufnr(2) == -1)
517 call <SID>Bf_Cycle(1)
519 call <SID>DEBUG('Tb_AutoUpdt: does not run for cycled windows', 9)
523 call <SID>DEBUG('Tb_AutoUpdt: does not run for the -TabBar- window', 9)
528 call <SID>DEBUG('EXIT : Tb_AutoUpdt()' ,10)
531 let g:Tb_UpdtMutex = 0
535 if (a:delBufNum != -1)
537 call <SID>DEBUG('Tb_AutoUpdt: will make sure that buffer '.a:delBufNum.' is not included in the buffer list.', 5)
541 " Only allow updates when the Tb_AutoUpdt flag is set
542 " this allows us to stop updates on startup.
543 if g:Tb_AutoUpdt == 1
544 " Only show TabBar if we have a real buffer
545 if ((g:Tb_MoreThanOne == 0) || (bufnr('%') != -1 && bufname('%') != ""))
546 if <SID>Bf_Eligible(a:delBufNum) == 1
547 " if we don't have a window then create one
548 let l:bufnr = <SID>Win_Find('-TabBar-')
551 call <SID>DEBUG('Tb_AutoUpdt: About to call Tb_Start (Create -TabBar-)', 9)
553 call <SID>Tb_Start(0, a:delBufNum)
555 " otherwise only update the window if the contents have changed
556 let l:ListChanged = <SID>Bf_BuildList(a:delBufNum, 0)
559 call <SID>DEBUG('Tb_AutoUpdt: About to call Tb_Start (Update -TabBar-)', 9)
561 call <SID>Tb_Start(0, a:delBufNum)
565 " go back to the working buffer
566 if (bufname('%') == '-TabBar-')
571 call <SID>DEBUG('Tb_AutoUpdt: Failed in eligible check', 9)
576 " VIM sometimes turns syntax highlighting off,
577 " we can force it on, but this may cause weird
578 " behavior so this is an optional hack to force
579 " syntax back on when we enter a buffer
580 if g:Tb_ForceSyntaxEnable
582 call <SID>DEBUG('Tb_AutoUpdt: Enable Syntax', 9)
588 call <SID>DEBUG('Tb_AutoUpdt: No buffers loaded...',9)
593 call <SID>DEBUG('EXIT : Tb_AutoUpdt are turned off',9)
598 call <SID>DEBUG('EXIT : Tb_AutoUpdt()' ,10)
601 let g:Tb_UpdtMutex = 0
605 " Tb_Click - Handle mouse double click ~~
606 function! <SID>Tb_Click()
608 call <SID>DEBUG('ENTER: Tb_Click()',10)
612 call <SID>DEBUG('EXIT : Tb_Click()',10)
618 "-------------------"
619 " Window operations "
620 "-------------------"
621 " Win_Find - Return the window number of a named buffer ~~
622 " If none is found then returns -1.
623 function! <SID>Win_Find(bufName)
625 " call <SID>DEBUG('ENTER: Win_Find()',10)
628 " Try to find an existing window that contains
630 let l:bufNr = bufnr(a:bufName)
633 " call <SID>DEBUG('Found buffer ('.a:bufName.'): '.l:bufNr,9)
635 let l:bufWinNr = bufwinnr(l:bufNr)
643 " Win_FindOrCreate - Attempts to find a window for a named buffer. ~~
645 " If it is found then moves there. Otherwise creates a new window and
646 " configures it and moves there.
648 " forceEdge, -1 use defaults, 0 below, 1 above
649 " isExplorer, 0 no, 1 yes
651 function! <SID>Win_FindOrCreate(bufName, forceEdge, isExplorer)
653 " call <SID>DEBUG('ENTER: Win_FindOrCreate('.a:bufName.')',10)
656 " Save the user's split setting.
657 let l:saveSplitBelow = &splitbelow
659 " Set to our new values.
660 let &splitbelow = g:Tb_SplitBelow
662 " Try to find an existing explorer window
663 let l:winNum = <SID>Win_Find(a:bufName)
665 " If found goto the existing window, otherwise
666 " split open a new window.
668 " if g:Tb_DBG_LVL > 0
669 " call <SID>DEBUG('Found window ('.a:bufName.'): '.l:winNum,9)
671 exec l:winNum.' wincmd w'
675 "if g:Tb_SplitToEdge == 1 || a:forceEdge >= 0
678 let l:edge = &splitbelow
680 let l:edge = a:forceEdge
685 exec 'bo sp '.a:bufName
687 exec 'bo vsp '.a:bufName
691 exec 'to sp '.a:bufName
693 exec 'to vsp '.a:bufName
700 " &splitbelow doesn't affect vertical splits
701 " so we have to do this explicitly.. ugh.
703 exec 'rightb vsp '.a:bufName
705 exec 'vsp '.a:bufName
710 let g:Tb_ForceDisplay = 1
712 " Try to find an existing explorer window
713 let l:winNum = <SID>Win_Find(a:bufName)
716 " call <SID>DEBUG('Created and then found window ('.a:bufName.'): '.l:winNum,9)
718 exec l:winNum.' wincmd w'
721 " call <SID>DEBUG('Win_FindOrCreate failed to create window ('.a:bufName.').',1)
727 " Turn off the swapfile, set the buffer type so that it won't get written,
728 " and so that it will get deleted when it gets hidden and turn on word wrap.
730 setlocal buftype=nofile
731 setlocal bufhidden=delete
736 exec('setlocal winwidth='.g:Tb_MinSize)
741 " call <SID>DEBUG('Window ('.a:bufName.') created: '.winnr(),9)
746 " Restore the user's split setting.
747 let &splitbelow = l:saveSplitBelow
752 " Win_Resize - Set width/height of -TabBar- window ~~
754 " Makes sure we are in our explorer, then sets the height/width for our explorer
755 " window so that we can fit all of our information without taking extra lines.
756 function! <SID>Win_Resize()
758 call <SID>DEBUG('ENTER: Win_Resize()',10)
761 " Make sure we are in our window
762 if bufname('%') != '-TabBar-'
763 call <SID>DEBUG('EXIT : Win_Resize called in invalid window',1)
767 let l:width = winwidth('.')
773 let l:length = strlen(getline('.'))
776 let l:height = winheight('.')
778 let l:height = (l:length / l:width)
779 " handle truncation from div
780 if (l:length % l:width) != 0
781 let l:height = l:height + 1
785 exec("setlocal textwidth=".l:width)
789 let l:height = line('.')
793 " enforce max window height
795 if g:Tb_MaxSize < l:height
796 let l:height = g:Tb_MaxSize
800 " enfore min window height
801 if l:height < g:Tb_MinSize || l:height == 0
802 let l:height = g:Tb_MinSize
806 call <SID>DEBUG('EXIT : Win_Resize to '.l:height.' lines',9)
808 exec('resize '.l:height)
814 let l:newWidth = s:maxTabWidth
815 if l:newWidth > g:Tb_MaxSize
816 let l:newWidth = g:Tb_MaxSize
818 if l:newWidth < g:Tb_MinSize
819 let l:newWidth = g:Tb_MinSize
822 let l:newWidth = g:Tb_VSplit
825 if l:width != l:newWidth
827 call <SID>DEBUG('EXIT : Win_Resize to '.l:newWidth.' columns',9)
829 exec('vertical resize '.l:newWidth)
838 "-------------------"
839 " Buffer operations "
840 "-------------------"
841 " Bf_Choosed - From the -TabBar- window, return the bufnum for buf under cursor ~~
842 " If we are in our explorer window then return the buffer number
843 " for the buffer under the cursor.
844 function! <SID>Bf_Choosed()
846 call <SID>DEBUG('ENTER: Bf_Choosed()',10)
849 " Make sure we are in our window
850 if bufname('%') != '-TabBar-'
852 call <SID>DEBUG('EXIT : Bf_Choosed: called in invalid window',1)
861 let l:retv = substitute(@",'\([0-9]*\):.*', '\1', '') + 0
864 call <SID>DEBUG('EXIT : Bf_Choosed: l:retv='.l:retv,5)
870 call <SID>DEBUG('EXIT : Bf_Choosed: return -1',1)
877 " Bf_DelWithD - From the -TabBar- window, delete selected buffer from list ~~
878 " After making sure that we are in our explorer, This will delete the buffer
879 " under the cursor. If the buffer under the cursor is being displayed in a
880 " window, this routine will attempt to get different buffers into the
881 " windows that will be affected so that windows don't get removed.
882 function! <SID>Bf_DelWithD()
884 call <SID>DEBUG('ENTER: Bf_DelWithD() g:Tb_VimBufList =['. g:Tb_VimBufList.'] g:Tb_BufferMap=['.g:Tb_BufferMap.']',10)
887 " Make sure we are in our window
888 if bufname('%') != '-TabBar-'
890 call <SID>DEBUG('EXIT : Bf_DelWithD not called in -TabBar-',1)
895 let l:selected_buf = <SID>Bf_Choosed()
896 let l:selected_buf = <SID>Map_Get_key( l:selected_buf )
898 call <SID>DEBUG('Bf_DelWithD: l:selected_buf=['.l:selected_buf.']',5)
900 let l:selected_name = bufname(l:selected_buf +0 )
902 call <SID>DEBUG('Bf_DelWithD: l:selBufName=['. l:selected_name.']',5)
905 let l:curLine = line('.')
906 let l:curCol = virtcol('.')
907 "make the filename an option
908 if l:selected_name == 'TabBar.DBG' && g:Tb_DBG_LVL > 0
910 call <SID>DEBUG('EXIT : Bf_DelWithD will not delete the debug window.',1)
915 let l:save_rep = &report
916 let l:save_sc = &showcmd
921 if l:selected_buf != -1 && l:selected_name != ""
923 " Don't want auto updates while we are processing a delete
925 let l:saveTb_AutoUpdt = g:Tb_AutoUpdt
926 let g:Tb_AutoUpdt = 0
928 " Save previous window so that if we show a buffer after
929 " deleting. The show will come up in the correct window.
931 let l:prevWin = winnr()
932 let l:prevWinBuf = winbufnr(winnr())
935 call <SID>DEBUG('Bf_DelWithD: l:prevWin='.l:prevWin.' buffer in window: '.l:prevWinBuf,5)
936 call <SID>DEBUG('Bf_DelWithD: l:selected_name=<'.l:selected_name.'>: l:selected_buf=['.l:selected_buf.']',5)
939 " If buffer is being displayed in a window then
940 " move window to a different buffer before
942 let l:winNum = (bufwinnr(l:selected_name) + 0)
943 " while we have windows that contain our buffer
946 call <SID>DEBUG('Bf_DelWithD: l:selected_buf='.l:selected_buf.' is being displayed in window: l:winNum='.l:winNum,5)
949 " move to window that contains our selected buffer
950 exec l:winNum.' wincmd w'
953 call <SID>DEBUG('Bf_DelWithD: We are now in window: '.winnr().' which contains buffer: '.bufnr('%').' and should contain buffer: '.l:selected_buf,5)
956 let l:origBuf = bufnr('%')
957 call <SID>Bf_Cycle(1)
958 let l:curBuf = bufnr('%')
961 call <SID>DEBUG('Bf_DelWithD: Window now contains buffer: '.bufnr('%').' which should not be: '.l:selected_buf,5)
964 if l:origBuf == l:curBuf
965 " we wrapped so we are going to have to delete a buffer
966 " that is in an open window.
969 " see if we have anymore windows with our selected buffer
970 let l:winNum = (bufwinnr(l:selected_name) + 0)
974 " Attempt to restore previous window
976 call <SID>DEBUG('Bf_DelWithD: Restoring previous window to: '.l:prevWin,5)
978 exec l:prevWin.' wincmd w'
980 " Try to get back to the -TabBar- window
981 let l:winNum = bufwinnr(bufnr('-TabBar-'))
983 exec l:winNum.' wincmd w'
985 call <SID>DEBUG('Bf_DelWithD: Got to -TabBar- window: '.winnr(),5)
989 call <SID>DEBUG('Bf_DelWithD: Unable to get to -TabBar- window',1)
993 " Delete the buffer selected.
995 call <SID>DEBUG('Bf_DelWithD: About to delete buffer: '.l:selected_buf,5)
997 " [displayed_buffer]-- [real_buffer] list
998 "let l:vimBuf = <SID>Map_Get_key( l:selected_buf )
999 exec('silent! bd '.l:selected_buf )
1001 let g:Tb_AutoUpdt = l:saveTb_AutoUpdt
1003 call <SID>DEBUG('Bf_DelWithD: current window=: '.bufname('%'),5)
1005 call <SID>Bf_SafePrint(1)
1006 call cursor(l:curLine, l:curCol)
1009 let &report = l:save_rep
1010 let &showcmd = l:save_sc
1013 call <SID>DEBUG('EXIT : Bf_DelWithD() g:Tb_VimBufList =['. g:Tb_VimBufList.'] g:Tb_BufferMap=['.g:Tb_BufferMap.']',10)
1018 " Bf_SafePrint - Wrapper for getting -TabBar- window shown ~~
1020 " Makes sure we are in our explorer, then erases the current buffer and turns
1021 " it into a mini buffer explorer window.
1022 function! <SID>Bf_SafePrint(delBufNum)
1024 call <SID>DEBUG('ENTER: Bf_SafePrint()',10)
1027 " Make sure we are in our window
1028 if bufname('%') != '-TabBar-'
1029 call <SID>DEBUG('EXIT : Bf_SafePrint not called in -TabBar-',1)
1033 " We need to be able to modify the buffer
1036 call <SID>Bf_PrintList(a:delBufNum)
1037 call <SID>Win_Resize()
1041 " Prevent the buffer from being modified.
1042 setlocal nomodifiable
1045 call <SID>DEBUG('EXIT : Bf_SafePrint()',10)
1050 " Bf_PrintList - Clear current buffer and put the -TabBar- text into it ~~
1051 " Makes sure we are in our explorer, then adds a list of all modifiable
1052 " buffers to the current buffer. Special marks are added for buffers that
1053 " are in one or more windows (*) and buffers that have been modified (+)
1054 function! <SID>Bf_PrintList(delBufNum)
1056 call <SID>DEBUG('ENTER: Bf_PrintList()',10)
1059 let l:ListChanged = <SID>Bf_BuildList(a:delBufNum, 1)
1061 if (l:ListChanged == 1 || g:Tb_ForceDisplay)
1062 let l:save_rep = &report
1063 let l:save_sc = &showcmd
1067 " Delete all lines in buffer.
1070 " Goto the end of the buffer put the buffer list
1071 " and then delete the extra trailing blank line
1073 put! =g:Tb_VimBufList
1075 let g:Tb_ForceDisplay = 0
1077 let &report = l:save_rep
1078 let &showcmd = l:save_sc
1081 call <SID>DEBUG('Buffer list not update since there was no change',9)
1085 call <SID>DEBUG('EXIT : Bf_PrintList()',10)
1090 " Bf_BuildList - Build the text for the -TabBar- window ~~
1091 " Creates the buffer list string and returns 1 if it is different than
1092 " last time this was called and 0 otherwise.
1093 function! <SID>Bf_BuildList(delBufNum, updateBufList)
1095 call <SID>DEBUG('ENTER: Bf_BuildList()',10)
1098 let l:NBuffers = bufnr('$') " Get the number of the last buffer.
1099 let l:i = 0 " Set the buffer index to zero.
1100 let l:y = 0 " Displayed buffers: more sugestive
1101 let l:fileNames = ''
1102 let l:maxTabWidth = 0
1103 call <SID>Map_Clear()
1105 " Loop through every buffer less than the total number of buffers.
1106 while( l:i <= l:NBuffers)
1109 " If we have a delBufNum and it is the current
1110 " buffer then ignore the current buffer.
1111 " Otherwise, continue.
1112 if (a:delBufNum == -1 || l:i != a:delBufNum)
1113 " Make sure the buffer in question is listed.
1114 if(getbufvar(l:i, '&buflisted') == 1)
1115 " Get the name of the buffer.
1116 let l:BufName = bufname(l:i)
1117 " Check to see if the buffer is a blank or not. If the buffer does have
1118 " a name, process it.
1119 if(strlen(l:BufName))
1120 " Only show modifiable buffers (The idea is that we don't
1121 " want to show Explorers)
1122 if (getbufvar(l:i, '&modifiable') == 1 && BufName != '-TabBar-')
1123 " Get filename & Remove []'s & ()'s
1124 let l:shortBufName = fnamemodify(l:BufName, ":t")
1125 let l:shortBufName = substitute(l:shortBufName, '[][()]', '', 'g')
1127 let g:Tb_BufferMap=g:Tb_BufferMap . l:y . "-" . l:i . "\r"
1128 let l:tab = '['.l:y.':'.l:shortBufName." ]"
1130 " If the buffer is open in a window mark it
1131 if bufwinnr(l:i) != -1
1132 let l:tab = "[".l:y.':'.l:shortBufName."]*"
1135 " If the buffer is modified then mark it
1136 if(getbufvar(l:i, '&modified') == 1)
1137 let l:tab = l:tab . '+'
1139 let l:maxTabWidth = <SID>Tb_Max(strlen(l:tab), l:maxTabWidth)
1140 let l:fileNames = l:fileNames.l:tab
1141 " If horizontal and tab wrap is turned on we need to add spaces
1143 if g:Tb_TabWrap != 0
1144 let l:fileNames = l:fileNames.' '
1146 " If not horizontal we need a newline
1148 let l:fileNames = l:fileNames . "\n"
1156 if (g:Tb_VimBufList != l:fileNames)
1157 if (a:updateBufList)
1158 let g:Tb_VimBufList = l:fileNames
1159 let s:maxTabWidth = l:maxTabWidth
1162 call <SID>DEBUG('EXIT : Bf_BuildList: Bf_List has changed',10)
1167 call <SID>DEBUG('EXIT : Bf_BuildList: no changes',10)
1174 " Bf_Eligible - Are there enough -TabBar- eligible buffers to open the -TabBar- window? ~~
1175 " Returns 1 if there are any buffers that can be displayed in a
1176 " mini buffer explorer. Otherwise returns 0. If delBufNum is
1177 " any non -1 value then don't include that buffer in the list
1178 " of eligible buffers.
1179 function! <SID>Bf_Eligible(delBufNum)
1181 call <SID>DEBUG('ENTER: Bf_Eligible()',10)
1184 let l:save_rep = &report
1185 let l:save_sc = &showcmd
1189 let l:NBuffers = bufnr('$') " Get the number of the last buffer.
1190 let l:i = 0 " Set the buffer index to zero.
1191 let l:found = 0 " No buffer found
1193 if (g:Tb_MoreThanOne > 1)
1195 call <SID>DEBUG('Bf_Eligible : More Than One mode turned on',6)
1198 let l:needed = g:Tb_MoreThanOne
1200 " Loop through every buffer less than the total number of buffers.
1201 while(l:i <= l:NBuffers && l:found < l:needed)
1204 " If we have a delBufNum and it is the current
1205 " buffer then ignore the current buffer.
1206 " Otherwise, continue.
1207 if (a:delBufNum == -1 || l:i != a:delBufNum)
1208 " Make sure the buffer in question is listed.
1209 if (getbufvar(l:i, '&buflisted') == 1)
1210 " Get the name of the buffer.
1211 let l:BufName = bufname(l:i)
1212 " Check to see if the buffer is a blank or not. If the buffer does have
1213 " a name, process it.
1214 if (strlen(l:BufName))
1215 " Only show modifiable buffers (The idea is that we don't
1216 " want to show Explorers)
1217 if ((getbufvar(l:i, '&modifiable') == 1) && (BufName != '-TabBar-'))
1219 let l:found = l:found + 1
1227 let &report = l:save_rep
1228 let &showcmd = l:save_sc
1231 call <SID>DEBUG('EXIT : Bf_Eligible '.l:found.' eligible buffers of '.l:needed.' needed',6)
1233 return (l:found >= l:needed)
1237 " Bf_SwitchTo Switch to bufNum( parameter) buffer~~
1238 function! <SID>Bf_SwitchTo( bufNum)
1240 let l:vimbuf = <SID>Map_Get_key( a:bufNum )
1241 exec "b!" . l:vimbuf
1245 " Bf_CrSel - From the -TabBar- window, open buffer under the cursor ~~
1246 " If we are in our explorer, then we attempt to open the buffer under the
1247 " cursor in the previous window.
1248 function! <SID>Bf_CrSel()
1250 call <SID>DEBUG('ENTER: Bf_CrSel()' ,10)
1253 " Make sure we are in our window
1254 if bufname('%') != '-TabBar-'
1256 call <SID>DEBUG('EXIT : Bf_CrSel : called in invalid window',1)
1261 let l:save_rep = &report
1262 let l:save_sc = &showcmd
1266 let l:bufnr = <SID>Bf_Choosed()
1269 if(l:bufnr != -1) " If the buffer exists.
1271 let l:saveTb_AutoUpdt = g:Tb_AutoUpdt
1272 let g:Tb_AutoUpdt = 0
1273 " Switch to the previous window
1276 " If we are in the buffer explorer or in a nonmodifiable buffer with
1277 " g:Tb_ModSelTarget set then try another window (a few times)
1278 if bufname('%') == '-TabBar-' || (g:Tb_ModSelTarget == 1 && getbufvar(bufnr('%'), '&modifiable') == 0)
1280 if bufname('%') == '-TabBar-' || (g:Tb_ModSelTarget == 1 && getbufvar(bufnr('%'), '&modifiable') == 0)
1282 if bufname('%') == '-TabBar-' || (g:Tb_ModSelTarget == 1 && getbufvar(bufnr('%'), '&modifiable') == 0)
1284 " The following handles the case where -TabBar-
1285 " is the only window left. We need to resize so we don't
1286 " end up with a 1 or two line buffer.
1287 if bufname('%') == '-TabBar-'
1294 "exec('b! '.l:bufnr)
1295 call <SID>Bf_SwitchTo( l:bufnr)
1299 let g:Tb_AutoUpdt = l:saveTb_AutoUpdt
1300 call <SID>Tb_AutoUpdt(-1)
1304 let &report = l:save_rep
1305 let &showcmd = l:save_sc
1308 call <SID>DEBUG('EXIT : Bf_CrSel()',10)
1313 " Bf_DblClkSel - Double click with the mouse.~~
1314 function! <SID>Bf_DblClkSel()
1316 call <SID>DEBUG('ENTER: Bf_DblClkSel()',10)
1318 call <SID>Bf_CrSel()
1320 call <SID>DEBUG('EXIT : Bf_DblClkSel()',10)
1325 " Bf_Cycle - Cycle Through Buffers ~~
1326 " Move to next or previous buffer in the current window. If there
1327 " are no more modifiable buffers then stay on the current buffer.
1328 " can be called with no parameters in which case the buffers are
1329 " cycled forward. Otherwise a single argument is accepted, if
1330 " it's 0 then the buffers are cycled backwards, otherwise they
1331 " are cycled forward.
1332 function! <SID>Bf_Cycle(forward)
1334 " The following hack handles the case where we only have one
1335 " window open and it is too small
1336 let l:saveTb_AutoUpdt = g:Tb_AutoUpdt
1337 if (winbufnr(2) == -1)
1339 let g:Tb_AutoUpdt = 0
1342 " Change buffer (keeping track of before and after buffers)
1343 let l:origBuf = bufnr('%')
1349 let l:curBuf = bufnr('%')
1351 " Skip any non-modifiable buffers, but don't cycle forever
1352 " This should stop us from stopping in any of the [Explorers]
1353 " FIXME: infite loop
1354 while getbufvar(l:curBuf, '&modifiable') == 0 && l:origBuf != l:curBuf
1360 let l:curBuf = bufnr('%')
1363 let g:Tb_AutoUpdt = l:saveTb_AutoUpdt
1364 if (l:saveTb_AutoUpdt == 1)
1365 call <SID>Tb_AutoUpdt(-1)
1369 " the format for a map is something like:
1371 " idx: the number displayed in tabbar [idx:fooBar.txt]
1372 " key: the buffer number in which idx is hold
1373 function! <SID>Map_Get_key( idx )
1374 let l:i=matchstr( g:Tb_BufferMap, a:idx . "-[0-9]*\r" )
1375 let l:x=substitute (l:i , a:idx ."-", "","")
1376 let l:x=substitute (l:x , "\r", "","")
1380 function! <SID>Map_Get_idx( key )
1381 let l:i=matchstr( g:Tb_BufferMap, "[0-9]*-" , a:key."\r" )
1382 let l:x=substitute (l:i , "-".a:key, "","")
1383 let l:x=substitute (l:x , "\r", "","")
1388 " I know this is short, But it keeps the code clean
1389 function! <SID>Map_Clear()
1390 let g:Tb_BufferMap=''
1394 " DEBUG - Display debug output when debugging is turned on ~~
1395 " Thanks to Charles E. Campbell, Jr. PhD <cec@NgrOyphSon.gPsfAc.nMasa.gov>
1396 " for Decho.vim which was the inspiration for this enhanced debugging
1398 function! <SID>DEBUG(msg, level)
1400 if g:Tb_DBG_LVL >= a:level
1402 " Prevent a report of our actions from showing up.
1403 let l:save_rep = &report
1404 let l:save_sc = &showcmd
1408 " Debug output to a buffer
1409 if g:Tb_DebugMode == 0
1410 " Save the current window number so we can come back here
1411 let l:prevWin = winnr()
1413 let l:prevPrevWin = winnr()
1416 " Get into the debug window or create it if needed
1417 call <SID>Win_FindOrCreate('TabBar.DBG', 1, 0)
1419 " Make sure we really got to our window, if not we
1420 " will display a confirm dialog and turn debugging
1421 " off so that we won't break things even more.
1422 if bufname('%') != 'TabBar.DBG'
1423 call confirm('ERROR in window debugging code. Dissabling TabBar debugging.', 'OK')
1424 let g:Tb_DBG_LVL = 0
1426 " Write Message to DBG buffer
1427 let res=append("$",s:DBG_LN_CNT.':'.a:level.":\t".a:msg)
1431 " Return to original window
1432 exec l:prevPrevWin.' wincmd w'
1433 exec l:prevWin.' wincmd w'
1434 " Debug output using VIM's echo facility
1435 elseif g:Tb_DebugMode == 1
1436 echo s:DBG_LN_CNT.':'.a:level.':'.a:msg
1437 " Debug output to a file -- VERY SLOW!!!
1438 " should be OK on UNIX and Win32 (not the 95/98 variants)
1439 elseif g:Tb_DebugMode == 2
1440 if has('system') || has('fork')
1441 if has('win32') && !has('win95')
1442 let l:result = system("cmd /c 'echo ".s:DBG_LN_CNT.':'.a:level.':'.a:msg." >> TabBar.DBG'")
1445 let l:result = system("echo '".s:DBG_LN_CNT.':'.a:level.':'.a:msg." >> TabBar.DBG'")
1448 call confirm('Error in file writing version of the debugging code, vim not compiled with system or fork. Dissabling TabBar debugging.', 'OK')
1449 let g:Tb_DBG_LVL = 0
1451 elseif g:Tb_DebugMode == 3
1452 let g:Tb_DbgOutput = g:Tb_DbgOutput."\n".s:DBG_LN_CNT.':'.a:level.':'.a:msg
1454 let s:DBG_LN_CNT = s:DBG_LN_CNT + 1
1456 let &report = l:save_rep
1457 let &showcmd = l:save_sc
1465 " :TbStart .......... Open and/or goto Explorer
1466 " :TbStop .......... Close the Explorer if it's open
1467 " :TbAup .......... Update Explorer without navigating
1468 " :TbToggle ......... Toggle Tabbar
1469 "``````````````````````````````````````````````````````````````````
1472 " let g:Tb_SplitBelow=0 " Put new window above current or on the left
1473 " for vertical split
1474 " let g:Tb_SplitBelow=1 " Put new window below current or on the right
1475 " for vertical split
1476 " By default we are now forcing the Tabbar window to open up at the edge of
1478 " You can turn this off by setting the following variable in .vimrc:
1480 " let g:Tb_SplitToEdge = 0
1482 " o IN HORIZONTAL MODE
1483 " You can set the max height by setting this in .vimrc:
1485 " let g:Tb_MaxSize = <max lines: default 0>
1487 " Setting this to 0 will mean the window gets as big as
1488 " needed to fit all your buffers.
1491 " You can set the min height by
1492 " letting the following variable in your .vimrc:
1494 " let g:Tb_MinSize = <min height: default 1>
1496 " o IN VERTICAL MODE
1497 " By default the vertical explorer has a fixed width. If you put:
1499 " let g:Tb_MaxSize = <max width: default 0>
1501 " into your .vimrc then tabbar will attempt to set the width of the
1502 " tabbar window to be as wide as your widest tab. The width will not
1503 " exceed Tb_MaxSize even if you have wider tabs.
1505 " Accepting the default value of 0 for this will give you a fixed
1506 " width tabbar window.
1508 " -- You can specify a MinSize for the vertical explorer window by
1509 " putting the following in your .vimrc:
1511 " let g:Tb_MinSize = <min width: default 1>
1513 " This will have no effect unless you also specivy Tb_MaxSize.
1514 "````````````````````````````````````````````````````````````````
1517 " -- This stops the -TabBar- from opening
1518 " automatically until more than one eligible buffer is available.
1519 " You can turn this feature off by setting the following variable
1521 " Setting this to 0 will cause the TabBar window to be loaded even
1522 " if no buffers are available. Setting it to 1 causes the TabBar
1523 " window to be loaded as soon as an eligible buffer is read. You
1524 " can also set it to larger numbers. So if you set it to 4 for
1525 " example the TabBar window wouldn't auto-open until 4 eligibles
1526 " buffers had been loaded. This is nice for folks that don't
1527 " want an TabBar window unless they are editing more than two or
1530 " let g:Tb_MoreThanOne=1
1531 "``````````````````````````````````````````````````````````````````
1534 " -- To enable the optional mapping of Control + Vim Direction Keys
1535 " [hjkl] to window movement commands, you can put the following into
1538 " let g:Tb_MapWindowNavVim = 1
1540 " To enable the optional mapping of Control + Arrow Keys to window
1541 " movement commands, you can put the following into your .vimrc:
1543 " let g:Tb_MapWindowNavArrows = 1
1544 "``````````````````````````````````````````````````````````````````
1547 " -- To enable the optional mapping of <C-TAB> and <C-S-TAB> to a
1548 " function that will bring up the next or previous buffer in the
1549 " current window, you can put the following into your .vimrc:
1551 " let g:Tb_MapCTabSwitchBufs = 1
1552 "````````````````````````````````````````````````````````````````
1555 " -- To enable the optional mapping of <C-TAB> and <C-S-TAB> to mappings
1556 " that will move to the next and previous (respectively) window, you
1557 " can put the following into your .vimrc:
1559 " let g:Tb_MapCTabSwitchWindows = 1
1563 " If you set TabSwitchBufs AND ...TabSwitchWindows,
1564 " TabSwitchBufs will *BE* enabled and
1565 " TabSwitchWindows will be *NOT*.
1566 "``````````````````````````````````````````````````````````````````
1569 " -- If you would like to single click on tabs rather than double
1570 " clicking on them to goto the selected buffer.
1572 " let g:Tb_UseSingleClick = 1
1573 "````````````````````````````````````````````````````````````````
1576 " -- It is possible to customize the the highlighting for the tabs in
1577 " the TabBar by configuring the following highlighting groups:
1579 " Tb_Normal ............. for buffers that have NOT CHANGED and
1581 " Tb_Changed ............. for buffers that HAVE CHANGED and are
1583 " Tb_VisibleNormal ....... buffers that have NOT CHANGED and are
1585 " Tb_VisibleChanged ...... buffers that have CHANGED and are VISIBLE
1587 " You can either link to an existing highlighting group by
1588 " adding a command like:
1590 " hi link Tb_VisibleChanged Error
1592 " to your .vimrc or you can specify exact foreground and background
1593 " colors using the following syntax:
1595 " hi Tb_Changed guibg=darkblue ctermbg=darkblue termbg=white
1598 " If you set a colorscheme in your .vimrc you should do it
1599 " BEFORE updating the TabBar highlighting groups.
1601 " If you use other explorers like TagList you can put:
1603 " let g:Tb_ModSelTarget = 1
1605 " into your .vimrc in order to force TabBar to try to place selected
1606 " buffers into a window that does not have a nonmodifiable buffer.
1607 " The upshot of this should be that if you go into TabBar and select
1608 " a buffer, the buffer should not show up in a window that is
1609 " hosting an explorer.
1611 " let g:Tb_ForceSyntaxEnable = 1
1612 "````````````````````````````````````````````````````````````````
1615 " -- TabBar has a basic debugging capability.
1616 " let g:Tb_DebugLevel = 0 " TabBar serious errors output
1617 " let g:Tb_DebugLevel = 4 " TabBar all errors output
1618 " let g:Tb_DebugLevel = 10 " TabBar reports everything
1620 " You can also set a DebugMode to cause output to be target as
1621 " follows (default is mode 3):
1623 " let g:Tb_DebugMode = 0 " Errors will show up in a vim window
1624 " let g:Tb_DebugMode = 1 " Uses VIM's echo function to display on
1626 " let g:Tb_DebugMode = 2 " Writes to a file TabBarDBG.vim
1627 " let g:Tb_DebugMode = 3 " Store output in variable g:Tb_DbgOutput
1629 " Or if you are able to start VIM, you might just perform these
1630 " at a command prompt right before you do the operation that is
1632 "````````````````````````````````````````````````````````````````
1636 " 0.7. Removed mapping to <tt>, to avoid delayed response to <<
1637 " 0.6. Fixed the "delete with d" bug.
1639 " TODO: 0. When the tabbar is full, try to scroll it
1640 " 1. See what is goind on with the error "Not enough space"
1643 " 4. Better Document
1644 " 5. noremap in vimrc to <C-TAB> to update the buffer list
1645 " 6. noremap in vimrc to <?> to switch to -TabBar-
1646 "vim:foldmethod=marker vim:foldmarker=~~,%%