A.J.Mechelynck schrieb:
Zarko Coklin wrote:
I posted following question some time back:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Is it possible to have a setup in .vimrc so that every
time I select tag either through "CTRL-]" or by
holding CTRL and pressing left mouse click to open a
new buffer in a new tab?

and got following answer that works:
:map <C-]> :exe "tab stag" expand("<cword>")<CR>
:map <C-LeftMouse> :exe "tab stag"
expand("<cword>")<CR>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The trouble I am having at the moment is that this
approach leads to a quick proliferation of open file
tabs. Ideally, Vim should not open a new tab for the
the file that already has a tab. Rather, it should
simply reuse an existing tab and position itself
within an open tab. Is there a way to get that done?

Thanks in advance,
Zarko

I think it is possible, but not easy, and would require writing a custom function, especially if you want to still be able to have split windows. I'm not going to try. You may want to try for yourself, or change your behaviour.

See, among others:
    :help tabpagenr()
    :help tabpagewinnr()
    :help tabpagebuflist()
    :help bufname()
    etc.

Best regards,
Tony.

Another idea: Usage of 'switchbuf'
   :set switchbuf=useopen,usetab

Problem: Works with buffer names only
-> Get filename of tag and search it in the buffer list

i.e. (first move cursor to tag)
   :exe "tab sbuf" taglist(expand("<cword>"))[0].filename

HTH,
Andy

--
EOM



        
                
___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de

Reply via email to