加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在Vim中查找所有出现的变量?

发布时间:2020-12-16 01:20:48 所属栏目:安全 来源:网络整理
导读:在 vim中,如何在某个目录下的文件中查找所有出现的变量? 我知道vimgrep有时可以工作,但是它只查找文本,如果其他类具有相同名称的变量并且我只想要特定类下的变量,则它不起作用. 我该怎么办?或者我应该改为使用IDE? 为什么要在已有的IDE中使用另一个IDE?
在 vim中,如何在某个目录下的文件中查找所有出现的变量?

我知道vimgrep有时可以工作,但是它只查找文本,如果其他类具有相同名称的变量并且我只想要特定类下的变量,则它不起作用.

我该怎么办?或者我应该改为使用IDE?

为什么要在已有的IDE中使用另一个IDE? Vim是一个可配置的IDE,可用于不同的语言.

您可以使用代码的cscope到build a database.这个数据库

  • Allows searching code for:
    • all references to a symbol
    • global definitions
    • functions called by a function
    • functions calling a function
    • text string
    • regular expression pattern
    • a file
    • files including a file

Cscope的更多功能:

  • Curses based (text screen)
  • An information database is generated for faster searches and later reference
  • The fuzzy parser supports C,but is flexible enough to be useful for C++ and Java,and for use as a generalized ‘grep database’ (use it to browse large text documents!)
  • Has a command line mode for inclusion in scripts or as a backend to a GUI/frontend
  • Runs on all flavors of Unix,plus most monopoly-controlled operating systems.

创建数据库后,您可以使用变量,函数等的用法.

编辑(略加OT):
在代码上使用Vim时非常方便的另一个很酷的东西是使用Ctags的taglist插件:

The “Tag List” plugin is a source code browser plugin for Vim and provides an overview of the structure of source code files and allows you to efficiently browse through source code files for different programming languages.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读