简体   繁体   中英

C# hide and unhide comments

I am trying to find solution how to hide and unhide comments in VS2010. What i found is:

# region 
comments for code
#endregion

and:

http://holyhoehle.wordpress.com/2010/01/17/hide-comments-in-visual-studio/

but this one is not working in VS2010 or i don't know how to...

So maybe any one can help and offer some solution how to hide comments like:

string x = "...." //comment

this extension is no longer maintained

I made a Visual Studio extension that allows you to hide/show comments.
You can get it here:

for Visual Studio 2010-2013
for Visual Studio 2015-2017

You can highlight them one by one, Right-click, and choose Outlining > Hide Selection.

The keyboard shortcut for that maneuver is Ctrl+M, Ctrl+H.

Aside from setting the font color of the comments to the same as the background color (which is what that VS plugin that you mentioned does), there is no way to hide comments.

Multi line comments (prefixed with either // or /* */ are already collapsible, but single line comments are not natively. Your only option for those is to use the Ctrl - M H key chord for a temporary (while the file is open) collapse (as mentioned in @rfmodulator's answer), or remove them altogether.

*The default C# key chord for collapsing all collapsible blocks is Ctrl - M O

You could use this macro to collapse all of the XML comments. I suspect that's about as good as you're going to get.

There is no way other than changing the comment color to hide inline comments and I could see that leading to all sorts of problems.

要隐藏选定的代码或区域(首先选择区域),只需使用 Ctrl + M、Ctrl + H。这适用于任何选择。

Using shortcut keys : Simply select your comment or working code and the just press:

Ctrl+M, Ctrl+H -> To hide (this simply collapse your selected section and make small box preview)

Ctrl+M, Ctrl+U -> To uhide

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM