Ed Barbu
Ed Barbu

Reputation: 1639

Make/trick Visual C++ into indenting macros structure properly

Consider these macros

#define BEGIN(Parent) void Process(){

#define ELEMENT(Elem) RegisterElement(Elem);

#define END }

When using them, Visual Studio will not recognize ELEMENT as part of a child code block and thus not indent it properly

BEGIN(ParentClass)   <--- hit ENTER here and carret will go below `B` in begin, with no indentation
ELEMENT(m_member)
END

Is there a way to trick Visual Studio, as in a way I could code my macros or maybe some helpful pragmas so that Visual Studio recognizes the opening and closing scope of RegisterElement function and thus indend ELEMENT entries properly? Thanks

Upvotes: 1

Views: 307

Answers (1)

user1
user1

Reputation: 4131

Use Code alignment extension for VS 2013/12/10

Here's url: https://visualstudiogallery.msdn.microsoft.com/7179e851-a263-44b7-a177-1d31e33c84fd

From Edit->Code Alignment menu, select 'Align from caret'

enter image description here

Upvotes: 1

Related Questions