13

I use ctags with my Vim and I rely heavily on C-] and C-T to tag back and froth between various functions in my project.

But if the function is in a different file, I'd like Vim to automatically open it in a new tab instead of the current tab. If I pop my tag stack using the C-T, I'd like it go back to the original tab where I pressed by C-] instead of changing the file in the current tab. I don't like to have the same file opened in multiple tabs in Vim. This is the normal behavior for most IDEs and I am wondering if there is a way to do this in Vim?

4

3 回答 3

12
nmap <C-Enter> <C-w><C-]><C-w>T

这有帮助吗?你可能会想出类似的东西来回程。


好吧,我们需要决定想要的行为是什么。我们可以返回原始选项卡(不确定如何,仍在调查),但上面给出的映射下次将打开一个新选项卡。所以一段时间后你会得到很多标签。

或者我们可以这样做<C-w>C,这将关闭打开的选项卡并带我们回到原来的选项卡。我个人更喜欢这种工作方式(这样我就不会失去我在文件中的位置)我转到我想要的函数,在那里进行更正,然后返回到我开始的原始文件。让我知道,你想要什么(这不适合评论,所以我把答案放在这里)。

于 2009-02-11T23:35:35.107 回答
5

这可能会为您指明正确的方向:

http://vim.wikia.com/wiki/Open_every_buffer_in_its_own_tabpage

于 2009-02-11T23:19:30.747 回答
0

So, this is a feature I would like to see as well.

I'm not sure if it's possible.

What I usually do is

:tabnew :tag somepartsoffunction*

and press tab to use globbing to easily find tag.

Sure, it's not an ideal solution, but it works most of the time.

Unfortunately, with VIM tabbing isn't totally integrated since it's a new feature since 7.0. Most people I know that use VIM weren't even aware of tabs until I told them, so with that, I have a feeling there is no way to do it right now.

(I would love to be proven wrong)

于 2009-02-11T23:04:00.313 回答