vim、ctags 和同名标识符
vim + ctags
非常适合 C 项目,因为 C 不允许函数重载,并且由于基本的作用域设施,通常鼓励手动添加符号前缀。
在 C++ 中,函数经常被重载,并在子类中被重写。 这使得vim总是在“Ctrl + ]”
上跳转到错误类中的标签。 有没有办法让它表现得更聪明一点? 我知道我可以带来一个包含替代标签的列表,但是每当我想跳到定义时总是必须打开这个列表并按数字找到所需的标签,这真是太烦人了。
vim + ctags
works well for C projects, since C does not allow function overloading and, in general encourages manual prefixing of symbols due to rudimentary scoping facilities.
In C++, functions are frequently overloaded, and overridden in subclasses. This makes vim always jump to the tag in the wrong class on "Ctrl + ]"
. Is there a way to make it behave a little more intelligently? I know I can bring a list with tag alternatives, but that's insanely annoying to always have to bring up this list, and find a needed tag by number whenever I want to jump to definition.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
还有“tagNext”可移动到下一个标签(或 :tn)
There is also "tagNext" to move to the next tag (or :tn<enter>)
我经常使用 tjump 。 它支持制表符完成,这很有帮助。 如果找到多个标签,它会给出一个列表供您选择,如果只找到一个,它会直接跳转到该标签(不像 tselect)。
用法:
I use tjump a lot. It supports tab completion which is helpful. If multiple tags are found, it will give a list for you to select from, if only one is found, it will jump right to the tag (unlike tselect).
Usage:
我知道针对您的问题的两种解决方法(看来您也知道):
I know two workarounds for your porblem ( it seems you knew it too ):
您可以使用我的脚本,它可以帮助您通过键入类名的一些字母或特殊标签(如“字段”、“函数”、“构造函数”等)来选择所需的标签。
http://www.vim.org/scripts/script.php?script_id=2507
You can use my script which will help you to select tag you need by typing some letters of the class name or special tags like 'field', 'function', 'constructor', etc.
http://www.vim.org/scripts/script.php?script_id=2507