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

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

问题描述

我在我的Vim中使用ctags,并且我在很大程度上依赖于C-]和CT来标记我项目中各种函数之间的标记。

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天全站免登陆