Wednesday, February 1, 2012

use ctags and vim on freebsd

use ctags on freebsd

There are two ctags on freebsd :

ctags from base system : /usr/bin/ctags
exuberant ctags from ports : /usr/local/bin/exctags

If you are linux programmer (like me), then exctags is what you are looking for.

Install ctags from ports:

cd /usr/ports/devel/ctags
make install clean

Generate tags from current directory:
# cd /src/dir/
# /usr/local/bin/exctags -R

Note: a new tags file will be generated under the current directory.

Generate tags from specified directory and store the tag file to the specified path:
# /usr/local/bin/exctags -R -f /tmp/tags /src/dir/

Let exctags to read *.module file as a php script for Drupal:
/usr/local/bin/exctags -R -f /tmp/tags /src/dir/

Edit your ~/.vimrc:
" To display the tags for only the current active buffer:
let Tlist_Show_One_File=1

" toggle the taglist window.
" Note: press ctrl-v F6 to generate ^[[17~
nnoremap ^[[17~ :TlistToggle<CR>
"nnoremap <F6> :TlistToggle<CR>

Run this command in your vim:
:set tags=/tmp/tags

Add this line to your ~/.vimrc:
set tags=/tmp/tags


No comments: