morgancodes
morgancodes

Reputation: 25285

How can I easily indent header declarations with Visual Studio

I like for my c++ member variables and method declarations to all be indented by the same amount, so that they line up like this:

class SnipformationScheduler : public ParagraphformationFinishedResponder
{
    int                                         mCurrentSnipIndex; 
    vector<ParagraphFormationAnimation>         mParagraphAnimations;
public:
    vector<string>                              mSnippetIDs;
    MovementController*                         mMovementController;

    SnipformationScheduler();
    virtual ~SnipformationScheduler(void);
    void                                        tick();
    void                                        paragraphAnimationFinished();
};

Currently, I do this by pressing tab until I get to the correct number of indentations. Surely there's an easier way. Anybody know what it is?

Upvotes: 1

Views: 412

Answers (1)

Matt Kline
Matt Kline

Reputation: 10507

I don't believe there's an easier way. However, please uses spaces for alignment. Tabs, if you use them at all (some people have their editor set to enter several spaces when they hit the tab key), should be for indentation only.

The rationale behind this is that different people have tabs set to show up as a different number of spaces. If I use...

  • All spaces, everyone always sees the same thing in their editor. However, they can't control the width of indentations (this annoys me personally).

  • All tabs, people can set the width of the indentations, but things might not line up if other people use a different tab width than you.

  • Tabs for indentation and spaces for alignment, everyone is happy. Everything always lines up, and people can set the width of their indentations.

Upvotes: 5

Related Questions