On 2/6/08, Ben Schmidt <[EMAIL PROTECTED]> wrote:

> I don't use them all that much, but am beginning to a bit more and I tend
> to do so
> like this. I put each module I am working on in a different tabpage. So
> one
> tabpage will have windows open for a handful of important files in my
> backend
> module. Another tabpage will have windows open for a handful of important
> frontend
> files. Another tabpage has a single window open with my 'to do' list so I
> can take
> notes and remember where I am up to. Another tabpage has specs open for
> the
> various data formats I am dealing with, for reference. I can switch
> between them
> at will, depending on what I need to work on.
>
> Arguably clicking a tab or using gt is easier than selecting a file from a
> list of
> buffers which is potentially signficantly longer than you really want,
> too, due to
> a stack of unloaded buffers you no longer need, but which still hang
> around in the
> list.
>

Amen to that.  At first, I, like you, wasn't sold on the benefits of tab
pages, but have come
to rely on them more and more.  I thought that having the same buffer open
on different
tab pages was a weird feature.  But now that I partition my views of a
project with tab
pages, I can look at it in whichever perspective suits.  Quickly.

I also keep a todo list in its own tab, various source files with supporting
documents each in
their own pages, another tab open to the file explorer, and often one tab
page is dedicated
to Vim's helpful help files.

To quickly decide which tabpage I need to jump to in order to find a certain
file, I can either
use the :tabs command, or use the following combination of &guitablabel and
&guitabtooltip
functions.

In short, now that I am familiar with tab pages, I won't go back!

.gvimrc:
set guioptions+=e

function! GuiTabLabel() "{{{
let label = '(' . v:lnum . ')'
let bufnrlist = tabpagebuflist(v:lnum)

" Append the number of windows in the tab page if more than one
let wincount = tabpagewinnr(v:lnum, '$')
if wincount > 1
let label .= wincount
endif
if label != ''
let label .= ' '
endif

" Append the name of active buffer
let label .= pathshorten(bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]))
" Add '+' if one of the buffers in the tab page is modified
for bufnr in bufnrlist
if getbufvar(bufnr, "&modified")
let label .= '+'
break
endif
endfor

return label
endfunction "}}}


function! GuiTabTooltip() "{{{
" This function is called once per tabpage
" Start with the tab number followed by the number of windows in the tab
page
let wincount = tabpagewinnr(v:lnum, '$')
let label = 'Tab #' . v:lnum . ' - ' . wincount . ' window'
if wincount > 1
let label .= "s:\n"
else
let label .= ":\n"
endif

" list all buffers, putting a '+' in front of modified buffers
" v:lnum == current tab page being evaluated
let bufnrlist = tabpagebuflist(v:lnum)
" prepend '+' if one of the buffers in the tab page is modified
" prepend '%' for the window containing the cursor
let current = tabpagewinnr(v:lnum)
let i = 1
for bufnr in bufnrlist
let label .= bufnr
if i == current
let label .= '% '
else
let label .= ' '
endif
let i += 1
if getbufvar(bufnr, "&modified")
let label .= '+ '
else
let label .= ' '
endif
let name = bufname(bufnr)
if name != ''
let label .= name . "\n"
else
let label .= "[No Name]\n"
endif

endfor

return label
endfunction "}}}

set guitablabel=%{GuiTabLabel()}
set guitabtooltip=%{GuiTabTooltip()}

-- 
Erik Falor
Registered Linux User #445632 http://counter.li.org

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui