Reputation: 51817
We use .NET here at work and our project is a little mixed, with some VB and C#. Exuberant Ctags generates C# tags just fine for me following these instructions. However, I have yet to be able to figure out how to get it to generate tags for my VB.NET code. The only article I've found that was somewhat helpful is this one. But at 2003 it ranks just a few years old. The first thing I noticed is that this line:
--langmap=vb:.bas.cls.ctl.frm.vbs
Is wrong, and also old. I changed it to read:
--langmap=vb:.vb
That improved my results slightly, but it still doesn't seem to generate the expected behavior (e.g. when I :set tag=tags
and do ^] or g] on a function call or parameter, it has no tags).
This is what my ctags.cnf
file looks like (and I have verified that it's being used):
--langdef=vb
--langmap=vb:.vb
--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
--recurse
--exclude="bin"
--exclude="obj"
--fields=+ianmzS
--extra=+fq
--vb-kinds=cn
Any clue what I need to do to get proper support?
This is a snip from my tag file:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /[email protected]/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
Application.Designer.vb .\My Project\Application.Designer.vb 1;" kind:F line:1
Application.Designer.vb .\Nuts\My Project\Application.Designer.vb 1;" kind:F line:1
AssemblyInfo.vb .\My Project\AssemblyInfo.vb 1;" kind:F line:1
AssemblyInfo.vb .\Nuts\My Project\AssemblyInfo.vb 1;" kind:F line:1
AttachmentHandler.vb .\Utilities\AttachmentHandler.vb 1;" kind:F line:1
While my CS codebase generates tags like this:
SomeModel .\Client\Views\Models\Namespace\SomeModel.cs /^ public class SomeModel$/;" kind:c line:12 namespace:Views.Models.SomeModel access:public
Upvotes: 3
Views: 2130
Reputation: 76
Here is a working configuration, extracted from my ~/.ctags
, based on that from OP's and applying accepted answer edit.
I had to remove the label matcher as this prevented all Sub/Function matches (not sure why) and replace the (Public|Private|\b)
with (Public|Private)?
to get it to optionally match access modifiers (else it didn't match any without these modifiers for me).
--exclude="bin"
--exclude="obj"
--langdef=vb
--langmap=vb:.vb
--regex-vb=/^[ \t]*(Public|Private)?[ \t]*Sub[ \t]+([a-zA-Z0-9_]+)/\2/s,subroutine/i
--regex-vb=/^[ \t]*(Public|Private)?[ \t]*Function[ \t]+([a-zA-Z0-9_]+)/\2/f,function/i
--regex-vb=/^[ \t]*(Public|Private)[ \t]+([a-zA-Z0-9_]+)[ \t]+As[ \t]+/\2/v,variable/i
--regex-vb=/^[ \t]*(Public|Private)?[ \t]*Const[ \t]+([a-zA-Z0-9_]+)[ \t]+(As|=)[ \t]+/\2/c,const/i
--regex-vb=/^[ \t]*(Public)?[ \t]*Property[ \t]*(Get|Let|Set)[ \t]+([a-zA-Z0-9_]+)/\3/n,name/i
--regex-vb=/^[ \t]*(Public|Private)?[ \t]*Enum[ \t]+([a-zA-Z0-9_]+)/\2/e,enum/i
#--regex-vb=/^[ \t]*([a-zA-Z_]+):/\1/l,label/i
--recurse
--fields=+ianmzS
--extra=+fq
--vb-kinds=cn
Upvotes: 3
Reputation: 8982
Unless you follow a zero-indent coding convention your regular expressions won't work ;)
Try:
// Note the extra [ \t]* right after ^
--regex-vb=/^[ \t]*(Public|Private|\b)[ \t]*Sub[ \t]+([a-zA-Z0-9_]+)/\2/s,subroutine/i
Upvotes: 3