0

I need to hide some comments which cannot be collapsed in some cases. What is the best practice to do it?

#region test
//var a = "comment";
#endregion
anil shrestha
  • 2,136
  • 2
  • 12
  • 26

1 Answers1

0

There are some methods. But I prefer is using these two, since they are manageable:

  1. Hide Selection command using shortcut keys: Simply select your code either it's 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

  2. Try using region:

    #region region_name

     //your stuff
    

    #endregion

anil shrestha
  • 2,136
  • 2
  • 12
  • 26
  • Consider mentioning _which_ keyboard shortcut you are using. Not everyone has the defaults for **Edit.Hide Selection** –  May 26 '21 at 08:15
  • @MickyD It's a windows OS configuration key. – anil shrestha May 26 '21 at 09:24
  • Hope you don't mind but I have edited your answer. But yes, `Ctrl+M, Ctrl+H` is only recognised by Visual Studio as far as I am aware and interpreted as the default keyboard assignment for **Edit.Hide Selection**. Visual Studio also allows you to re-define the keyboard shortcut for it and many other commands. –  May 26 '21 at 10:33