16

Is there a Visual Studio preprocessor equivalent of #pragma mark found in XCode? Here's why I ask:

This is on Windows.

enter image description here

This is on Mac.

enter image description here

I know of #region in C#, but nothing of similar functionality in C++.

EDIT 12/03/2013:

#pragma region adds collapsibility to code, but doesn't add sections to VS's method listings, which is essentially what I'm looking for. I much prefer to jump to methods quickly using the function listing, especially in large classes/files where scrolling through a forest of code is a no-no; the "sectioning" really shines in such cases.

I was really expecting Visual Studio to have this kind of functionality, seems like something pretty basic. Pretty sure Eclipse lets you do this with the Coffee-Bytes plugin too.

KillAWatt1705
  • 645
  • 1
  • 6
  • 13

3 Answers3

4

You can use #pragma region:

#pragma region foo
// some code ...
#pragma endregion foo
Carsten
  • 11,287
  • 7
  • 39
  • 62
Shmil The Cat
  • 4,548
  • 2
  • 28
  • 37
  • Thanks for the answer. But does this show up as "sections" in the method listing in Visual Studio? – KillAWatt1705 Mar 12 '13 at 15:38
  • 1
    I'm using VS2012 and the "sections" don't appear in the listing :( but at least one can collapse the "section" in the main Editor window – Shmil The Cat Mar 12 '13 at 16:00
  • 1
    Yeah, the collapsibility is nice, but doesn't seem to be adding sections to the method listing on VS2010 either. I much prefer to jump to methods quickly in the function listing, especially in large classes/files, the sectioning really helps with that. Maybe there's a plugin that adds organisational features to VS and does this? – KillAWatt1705 Mar 12 '13 at 17:30
1

Apparently, it is not in Visual studio 2015 and I don't think it will be in the near future. [Reference]

Thanks for taking the time to share this suggestion. This item has been around for a couple of versions of Visual Studio and we haven’t acted on it. Looking at the VS “15” plans, we’re not going to take action on this item, so we’re going to close it. If the suggestion is still relevant, please either take a look to see if there’s another suggestion that’s similar that you can vote on, or open a new suggestion.

FrankS101
  • 2,112
  • 6
  • 26
  • 40
0

This is kind of an ugly solution but still better than nothing :D :

#if false
int ________visualization________;
#endif

The function listing displays variables with a different mark than methods + the underscores visually form a line so you can easily find the mark and it "nicely" segments the listing.

Note: tested in VS Code, not in Visual Studio itself, I can't see any variables in your listing so in the case that VS listing doesn't display the variables you will need to use void ________visualization________(){} instead.