db Documentation

What is “db” ?

简单来说,用此工具集成vim+cscope+ctags,可以把vim作为一个IDE来用,特别是你只有console的时候。用cscope来看20G的Android源代码毫无压力。
db is a wrapper tool to manage cscope and ctags projects.
You will love ctags+cscope+vim with this tool.

Installation

0. Requirements

Installing “db” tool is easy. However, you do need a couple of other things installed first.

  • ctags
  • cscope
  • git
  • gradle

1. fetch code

git clone https://github.com/cfig/utils

2. make and install

$ cd db_tool
$ gradle install

3. let vim load cscope/ctags database automatically

modify .vimrc as follows:

"taglist
if $SELECT_PROJECT_DB != ""
    if filereadable(expand("~/.proj_db/$SELECT_PROJECT_DB/tags"))
        set tags=~/.proj_db/$SELECT_PROJECT_DB/tags;
    endif
    if filereadable(expand("$HOME/.proj_db/$SELECT_PROJECT_DB/cscope.out"))
        " for M$ compatible
        cd $HOME
        cs add .proj_db/$SELECT_PROJECT_DB/cscope.out
        cd -
    endif
else
    set tags=tags; " the ';' is a must!
endif

Getting started

1. create project

$ db init my_project my_project2

This will create empty projects with name “my_project” and “my_project2” in ~/.proj_db/

2. check all projects you just created.

yu@mint ~ $ db list
1 - my_project
2 - my_project2
yu@mint ~ $ 

3. choose a project as “current” active project

$ dbc 1

4. add directories into current project

$ cd <your_source_directory>
$ db +

repeat these steps, until you add them all. You can check which directories are added into current project by “db show”.

5. generate cscope/ctags

$ db make

This may take some time if your project is huge. It takes up to 40 min for my whole Android source tree.

6. once the index is ready, you can open vim, and search anything you wanted.

Don’t know how to search with cscope ?
Check this http://cscope.sourceforge.net/cscope_vim_tutorial.html