Adding Support for Visual Basic to Exuberent Ctags

jEdit has a great source code navigation plugin called Tags which uses Exuberant Ctags. By default Ctags doesn't support VB, which I'm seeing a lot of lately, but it does allow one to add support for laguages using regular expressions.

I added the following to c:\ctags.cnf:

--langdef=vb
--langmap=vb:.bas.cls.ctl.frm.vbs
--regex-vb=/^(Public|Private|\b)[ \t]*Sub[ \t]+([a-zA-Z0-9_]+)/\2/s,subroutine/i
--regex-vb=/^(Public|Private|\b)[ \t]*Function[ \t]+([a-zA-Z0-9_]+)/\2/f,function/i
--regex-vb=/^(Public|Private)[ \t]+([a-zA-Z0-9_]+)[ \t]+As[ \t]+/\2/v,variable/i
--regex-vb=/^(Public|Private|\b)[ \t]*Const[ \t]+([a-zA-Z0-9_]+)[ \t]+(As|=)[ \t]+/\2/c,const/i
--regex-vb=/^(Public|\b)[ \t]*Property[ \t]*(Get|Let|Set)[ \t]+([a-zA-Z0-9_]+)/\3/n,name/i
--regex-vb=/^(Public|Private|\b)[ \t]*Enum[ \t]+([a-zA-Z0-9_]+)/\2/e,enum/i
--regex-vb=/^([a-zA-Z_]+):/\1/l,label/i

These expressions probably aren't perfect, but I've found them to work pretty well. If you've got suggestions or improvements, please send them along.

Example output:

C:\Code\CASS\SMSSource>ctags -RV
RECURSING into directory "."
ignoring .\.cvsignore (unknown language)
ignoring .\360.ico (unknown language)
OPENING .\Advertiser.cls as vb language file
OPENING .\Advertisers.cls as vb language file
OPENING .\Affidavit.cls as vb language file
^C
C:\Code\CASS\SMSSource>

Here's a screen shot of the plugin in action:

[screen shot of Ctags w/VB in jEdit]

Tagged with: ctags vb jedit

posted April 17th, 2003