Visual Studio IntelliSense for viewing block decla

2019-04-16 13:55发布

问题:

I'm really curious if anyone knows if Visual Studio's IntelliSense can be configured to display a code block's declaration by hovering over the block's closing brace (or something similar).

Rather than having to mark long code blocks with a comment, I would much rather hover over the closing brace to view which block it ends.

If what I'm saying isn't clear, imagine you had the code block below:

if (typeof(obj) is Int32)
{
    ///...PROGRAM LOGIC...
}

In this example, if I were to move the caret to the end brace, right-click the end brace, or simply hover over it. A popup window would show giving me the original declaration at the top:

if (typeof(obj) is Int32) { //...


Also, I'm interested to know if this can be done in Eclipse; I've asked that question here.

回答1:

This is now available in Visual Studio 2015.



回答2:

Looks like VSCommands for Visual Studio 2013 adds this exact functionality.

It's in "always on" mode by default (shown above), but personally, I find that annoying and change it to display the icon & tooltip only -- then when you hover over the icon you get a pop-up tooltip like you describe (the rest of the Extension is also very cool, it allows you to right click and compare files, even if they're not under source control, right click -> zip solution, all kinds of cool stuff).

To configure the feature, after installing the extension and restarting Visual Studio, open Tools -> Options -> VSCommands 12 -> Open Configuration. This opens a Configuration page (similar to project settings, etc.)

So, close the options dialog at this point and in the Configuration page, find IDE Enhancements -> Text Editor and Check Enable Code Block End Tagger (I also recommend either using Double-Click or Ctrl+Click navigation). Turn off "Show only when block beginning not visible", and then set Display Mode to "Icon Only".

And this is what you get (note the mouse cursor is missing in the screen shot, but I'm hovering over the closing brace):