I recently discovered ctags, a program that generates a tag/index file for C, Java, PHP, Python, Ruby. For those new to the Ingres source ctags is an invaluable tool for navigating the Ingres source tree. Editors like vi and Emacs can use the generated tag file to allow the coder to go directly to the source for any Ingres function.
Here is how to setup ctags with Vim:
- Install ctags for your operating system
- Linux distributions normally have a ctags package available
- The source for ctags can be obtained from http://ctags.sourceforge.net/
- Windows users can get ctags from http://ctags.sourceforge.net/
- Generate the tag file for the Ingres source:
ctags -R -f ~/.vim/tags/ingres.ctags /home/grant/src/svn/ingres/main/ - ~/.vim/tags/ingres.ctags is the target tag file. Windows: Use $HOME in place of ~
- /home/grant/src/svn/ingres/main/ is the full path to the Ingres source tree. The path used needs to absolute and not relative since Vim will need to navigate from the current working directory to the file containing the function definition.
- Copy the following code into your $HOME/.vimrc:
" Tag files
set tags+=$HOME/.vim/tags/ingres.ctags
" Ctrl+Right Arrow to goto source of function under the cursor
map <silent><C-Left> <C-T>
" Ctrl+Left Arrow to go back
map <silent><C-Right> <C-]>
- Open any Ingres source file with Vim, say main/src/common/odbc/driver/connect.c
- Search for IIapi_initialize, somewhere around line 2276 (at least on my system)
- Place the cursor over the function IIapi_initialize and then press Control+Right Arrow/Cursor
- Vim should have loaded main/src/common/aif/aip/apiinit.c and placed the cursor on the following line (309):
IIapi_initialize( IIAPI_INITPARM II_FAR *initParm ) - To go back to the previous file press Control+Left Arrow/Cursor
There you have it a simple way of navigating the Ingres source from the relative comfort of Vim.