Skip to content

Navigating the Ingres source with … ctags

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:

  1. Install ctags for your operating system
  2. 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.
  3. 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-]>
  4. Open any Ingres source file with Vim, say main/src/common/odbc/driver/connect.c
  5. Search for IIapi_initialize, somewhere around line 2276 (at least on my system)
  6. Place the cursor over the function IIapi_initialize and then press Control+Right Arrow/Cursor
  7. 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 )
  8. 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.

  • Share/Bookmark

Some random posts

  • Paul Mason
    The other thing you can do with ctags which is pretty cool, is

    vi -t IIapi_initialize

    and it will take you to the first file with that symbol in and take you to that line in the file. It'll also load a 'stack' of other file references which you can then navigate through. There are different ways to do so :tn and :tp will take you to the next and previous occurrences respectively, and :ts will allow you to select from a list.

    :help tags opens a help file with full description of how to use tags with vim.
blog comments powered by Disqus