VIM:更精确的 C/C++ 代码解析解决方案? [英] VIM: More precise C/C++ code parsing solutions?

查看:28
本文介绍了VIM:更精确的 C/C++ 代码解析解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前:我已经在 VIM 工作了大约一年了.很多很棒的东西:组合,脚本.每当我在不同的编辑器中编辑内容时,如果没有 VIM 的导航,我会感到迟钝/不舒服.

Pre: I've been working in VIM for like a year already. Lots of great things: combinations, scripts. Whenever I'm editing something in a different editor, I feel sluggish/uncomfortable without VIM's navigation.

问题:最让我困扰的是使用现有工具(ctags、cscope)进行源代码导航.通常,ctags 找不到变量的声明,与 ctags 相对的 cscope 查找具有相同变量名称的所有定义.与调用树导航相同的疯狂,查找前向声明以及单个类定义等.与 Eclipse 中的 MS Intellisense、Visual Assist 甚至源代码导航相比,Exuberant Tags/cscope 似乎至少被弃用了 10 年.

The problem: The thing that really bothers me most of all is source code navigation using existing tools (ctags, cscope). Often, ctags can't find the declaration of a variable, cscope as opposed to ctags finds all definitions with the same variable name. Same craziness with call tree navigation, finding forward declarations along with a single class definition etc. Compared to MS Intellisense, Visual Assist or even source code navigation in Eclipse, Exuberant Tags/cscope seems to be deprecated for at least 10 years.

我知道有像 ViEMU 这样的工具,但它们并不能真正解决问题,因为你失去了很多 VIM 的功能.

I know there are tools like ViEMU, but they don't really solve the problem, since you lose lots of VIM's functionality.

问题:我想知道是否有一种工具可以更好地进行源解析,或者有什么方法可以将 Intellisense 等源解析引擎集成到 VIM 中?也许有商业解决方案,或者有人准备实施?

The question: I was wondering if there is a tool that does the source parsing better, or there is some way to integrate source parsing engines like Intellisense into VIM ? Maybe there are commercial solutions or there are people who are ready to implement one ?

与通过单个 Alt-G 快捷键完成的 Visual Assist 相比,VIM 的所有优点似乎比导航到类定义时浪费的时间节省的时间更少.

All the benefits of VIM seem to save less time than is being wasted while navigating to class definition, compared to Visual Assist, where it's done by a single Alt-G shortcut.

推荐答案

搜索和调用树

您可以尝试 eclim,这是一种在 Vim 中使用某些 Eclipse 功能的方法.

Search and Call tree

You could try eclim, which is a way to use some Eclipse features in Vim.

对于 C/C++,它提供:

For C/C++, it provides :

  • 上下文相关的完成(尽管它在 Windows 上被禁用,因为它有问题)
  • 项目文件中的上下文相关搜索(通过:CSearchContext)
  • 函数/方法的调用树(:CCallHierarchy)
  • 代码验证 (:Validate)

这不是很好,但在某些情况下可以提供帮助.

It is not great, but it can help in some cases.

关于自动代码完成,我主要使用 OmniCppComplete,它是使用标签提供上下文感知代码完成.没那么糟.

Regarding automatic code completion, I primarily use OmniCppComplete, which is using tags to provide Context aware code completion. It is not that bad.

根据 Luc Hermitte 的建议,您还可以使用 clang_complete不需要ctags,但需要安装clang.

As advised by Luc Hermitte, you can also use clang_complete which does not need ctags, but needs clang installed.

这篇关于VIM:更精确的 C/C++ 代码解析解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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