Tag Archives: exuberant ctags

Vim as a Source navigator

It all started with my quest to master the vim, after I got feel of using vim I decided it was time to start using vim to read code as well.

I have a project with a lot of files, I would generally use the Source Insight tool, on windows, to jump to definitions across files effortlessly. To do the same in linux, I found this plugin Taglist which could be used for source code browsing.

With the enthusiasum of the new found plugin, I wanted to download the plugin and use it straight away. But as a guy who only used linux to build projects, my lack of knowledge on installing the plugin and getting working took me around 2 hours of digging around and internet to find all the information.

This should serve as a guide for you(and as a reference to me)

1) Vim version
Supports only 6.0 and above. If you don’t have vim or you have an older version of vim use these commands (you will need root permission)

// installing vim
$sudo apt-get install vim

// updating vim
$sudo apt-get update vim

2) Install the “Exuberant Ctags”
Taglist only works with the exuberant ctags. Check if the exuberant ctags is already installed on your machine

// fire up vim
$vim
// run this command
$:echo system(Tlist_Ctags_Cmd . ' --version')

You should see the name – Exuberant Ctags followed by the version number. If you don’t see it then it is not installed, follow the steps below to install it. If it is installed then you can go to step 3

If you have root permissions then you can use apt-get install to get the package and install it however if you don’t have root permissions then you will need to download the sources and build it. Follow the below steps to build and install

// download the source from - http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz or the latest one
// run these commands
$ tar zxf ctags-5.8.tar.gz
$ cd ctags-5.8
$ ./configure --prefix=$HOME
//this builds and installs it /home/user/bin directory
$ make && make install

// modify your PATH variable to include the bin dir
// open your shell configuration file
$ vim $HOME/.bashrc

// add this to the configuration file
export PATH="$HOME/bin:$PATH"

// resource the configuration file
$source $HOME/.bashrc

// restart shell without closing it
$ . $HOME/.bashrc

3) Next step is to tell vim where the ctags have been installed

// open your .vimrc file and add this line
let Tlist_Ctags_Cmd="home/user/bin/ctags"

Note: It should point to the ctags file and not to the directory containing it.

4) Turn on Vim filtype detection.

// open your .vimrc file and add this line
filetype on

5) Now restart vim by opening up a source file, you can toggle the tag window using the command
:TlistToggle

If you are still having problems, check the FAQ.

Compiled from:
http://superuser.com/questions/66367/is-it-possible-to-install-ctags-without-root-privs
http://www.vim.org/scripts/script.php?script_id=273