在 Vim 中标记函数时如何使用多个选项卡 [英] How to use multiple tabs when tagging to a function in Vim

查看:25
本文介绍了在 Vim 中标记函数时如何使用多个选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Vim 中使用 ctags,我严重依赖 C-] 和 C-T 在项目中的各种函数之间来回标记.

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.

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

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?

推荐答案

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.

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

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).

这篇关于在 Vim 中标记函数时如何使用多个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆