Dan W
Dan W

Reputation: 3628

Searchable custom tags for Visual Studio 2010?

I want to tag certain parts of my code with various words, and then find them later.

For example, if I add these tags to a function like this...

// #variable #clipboard #select
public void myfunc() {
    // Lots of code...
}

...then I want to be able to search for those tags, even in reverse order! For example, I might search for: clipboard variable, and it would find the function. Alternatively, I might search for something where one term isn't in the tag list. For example, select clipboard key. Although key isn't a tag, two of the words match, so Visual Studio would put it at (or near) the top of the search results.

How can I achieve this? It would GREATLY simplify hunting for old pieces of code.

Upvotes: 2

Views: 50

Answers (2)

Mare Infinitus
Mare Infinitus

Reputation: 8172

Perhaps you can use the MetadataType attribute in your code.MSDN for metadata type

If you want it searchable and easy to manage, the tool of choice is something like Atlassian fisheye. I think sventon (as an alternative to that) is no longer active.

Upvotes: 0

Superdoggy
Superdoggy

Reputation: 218

So if I understand your problem, you want to be able to find any block of code with arbitrary keywords? I took a look at all of the Visual Studio 2010 find/replace tools but I don't think that any of them will really be what you're hoping for. My only solution that I think might work for arbitrary ordering of keywords would be if you were to write your commented out code like

//clipboard variable select clipboard select variable clipboard select variable clipboard select clipboard variable...

Obviously that's a very tedius workaround, but it technically could help if there was some code that you really did not want to lose. One thing to remember is that C# is not responsible for keeping code organized and easy to navigate - that's completely up to the programmer.

Instead of trying to use keywords to find important methods within a gigantic block of text, I suggest minimizing methods or classes that you're not currently using. If you've finished writing the method/class, you should click the [-] sign to the left of the start of the method/class so that it doesn't take up so much space. If you minimize your code properly, things shouldn't be nearly as hard to find.

Hope this helps!

Upvotes: 1

Related Questions