在 Vim 中标记函数时如何使用多个选项卡

发布于 2024-07-13 22:33:18 字数 234 浏览 3 评论 0原文

我在 Vim 中使用 ctags,并且严重依赖 C-] 和 CT 在项目中的各个函数之间进行标记。

但如果该函数位于不同的文件中,我希望 Vim 自动在新选项卡而不是当前选项卡中打开它。 如果我使用 CT 弹出标签堆栈,我希望它返回到我按 C-] 的原始选项卡,而不是更改当前选项卡中的文件。 我不喜欢在 Vim 的多个选项卡中打开同一个文件。 这是大多数 IDE 的正常行为,我想知道是否有办法在 Vim 中做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

余生一个溪 2024-07-20 22:33:18
nmap <C-Enter> <C-w><C-]><C-w>T

这有帮助吗? 你也许可以在回来的路上找到类似的东西。


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

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

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

Does this help ? You could probably figure out something similar for the way back.


Well, we need to decide what would be the wanted behaviour. We can go back to the original tab (not sure how, still investigating) but then the above given mapping is gonna open a new tab next time. So you'll end up with a lot of tabs after a while.

Or we can do <C-w>C, which will close the opened tab and take us back to the original one. I, personally, prefer this way of working (that way I don't lose my position in the file)
I go to the function I want, make my corrections there then return to the original file from which I started.
Let me know, what would you like (this didn't fit in comments so I put the answer here).

双手揣兜 2024-07-20 22:33:18

所以,这也是我希望看到的一个功能。

我不确定是否可能。

我通常做的是

:tabnew
:tag 函数*的一些部分

并按 Tab 键使用通配符轻松查找标记。

当然,这不是一个理想的解决方案,但它在大多数情况下都有效。

不幸的是,VIM 选项卡并未完全集成,因为它是 7.0 以来的新功能。 我认识的大多数使用 VIM 的人甚至都不知道选项卡,直到我告诉他们,所以我感觉现在没有办法做到这一点。

(我很乐意被证明是错的)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文