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