Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio C# statement collapsing

People also ask

Microsoft Visual C++ buat apa?

Fungsi Microsoft Visual C++Microsoft Visual C++ adalah lingkungan pengembangan terintegrasi (IDE) yang digunakan untuk membuat aplikasi Windows dalam bahasa pemrograman C, C++, dan C++ / CLI. Program ini menawarkan engembang aplikasi tunggal di mana mereka dapat menulis, mengedit, menguji, dan men-debug kode mereka.

Apa itu VC Redist?

Microsoft Visual C++ Redistributable ini merupakan library tambahan dari program yang dibuat dengan bahasa C++ menggunakan Microsoft Visual Studio. Karena program ini mungkin menggunakan fitur yang tidak standar atau bukan bawaan Windows, maka perlu menginstall library baru untuk memanfaatkan secara penuh.


Starting with Visual Studio 2017, statement collapsing is built-in.

There are several extensions that perform this task for pre-2017 versions of VS, starting with VS 2010 version:

The last extension supports only VS 2015 and VS 2017, but it's the most powerful one.
It supports syntax coloring inside collapsed blocks, it is more fault-tolerant and optimized.

If the extension doesn't seem to install after you used a browser to download it, try using the built-in Visual Studio extension manager.


I'm not aware of add-ins, but you mentioned regions and I see nothing wrong with doing something like this...

foreach (Item i in Items)
{
  #region something big happening here
  ...
  #endregion

  #region something big happening here too
  ...
  #endregion

  #region something big happening here also
  ...
  #endregion
}

EDIT: In response to the question's EDIT: You're right, sticking a bunch of regions everywhere isn't ideal and refactoring is probably the way to go. But it seems that you're looking for something magical that will "organize" the code for you, and I don't think that exists.


You can collapse specific blocks of text within visual studio, but you have to turn off automatic outlining.

Right click in your code window and select (Outlining | Stop Outlining)

Then, select some text, right click and select (Outlining | Hide Selection)

When you turn on automatic outlining again, your custom "Regions" will no longer collapse.


Visual Studio 2008 supports regions inside of functions as long as you keep them in the same code hierarchical level

#region Won't work
for(int i = 0; i<Count; i++)
{
//do something
#endregion
}

for(int i=0; i<Count; i++)
{
#region Works fine
//do lots of stuff
#endregion
}

Let me say something different: press(ctrl+m,ctrl+h) or in edit>outlining>hide selection its so useful.