CTags and VIM

Sample generate tags file command
ctags -f {tag file location} --recurse --langmap=C++:.C.h.c.cpp.hpp --languages=C++ --extra=+q --fields=+i --verbose
{source parent folder e.g. /usr/my_source/}
After tag file generated, add
set tags={tag file location 1}, {tag file location 2} to .vimrc
in VIM
type

:set tags={tag file location 1}, {tag file location 2}

or add it to .vimrc
in VIM


For ultraedit, the ctag parameter is

-L %fi -f %fo --language-force=C++ --extra=+q --fields=+i



If using VIM as editor, the supported commands are

:ts - tag, class definition as priority
:tj - tag (can use /pattern or /^pattern. Since it is pattern search, it is not binary search mode which would be slow)
:po or ctrl + 't' - older tag search stack
ctrl ']' on selected text to call tag search directly.
: or to scroll for previous calls

(refer http://www.vim.org/htmldoc/tagsrch.html )

VIM commands which is useful when use in conjunction with ctags
shift + * - start to search this word in the document
shift + # - start to search this word in the document (backward order)
n - continue to search forward the word
shitf + n - continue to search backward for the word.
:e - to reload the current document in VIM.
/ (command mode) - to search for a word (using regex if supply) in forward order
? (command mode) - to search for a word (using regex if supply) in backward order.
:file - to show current edit/view file in VIM
ctrl + [ or ctrl ] or ctrl % - nagivate source files.
:e - to open another file as another page buffer in VIM.
:E - to open another file using a file explorer of VIM
:bn - move to next page buffer in VIM.
:bp -
move to previous page buffer in VIM.
:bd - close current page buffer in VIM.
:files - show all page buffer loaded in VIM.
:%s///g - to replace all the source string to destination string.


If run Ctag from the shell, type vim -t {tag file} and then select which tag position to start edit with

Comments

Unknown said…
There is no recursive option in Ubuntu that I can tell..

$ ctags --version
ctags (GNU Emacs 22.1)

$ ctags --recurse *
ctags: unrecognized option `--recurse'
Try `ctags --help' for a complete list of options.
Unknown said…
strange. on a different Ubuntu server we have, this all works...

$ ctags --version
Exuberant Ctags 5.7, Copyright (C) 1996-2007 Darren Hiebert
Compiled: Jun 11 2008, 21:08:30
Addresses: dhiebert@users.sourceforge.net, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
You have to install 'exuberant-ctags' package in Ubuntu. The GNU Emacs version is not accepting normal parameters. I don't know the reason. But this works for me after I install the above mentioned package.
http://mpathirage.com

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file

MSSQL GROUP_CONCAT