Here comes the first informative post. This is something I learnt today. I have been working on dynamic code generation and the code filed generated always seemed to be a bit out on formatting. What I did was selected each line and then either pressed the tab key on my keyboard, or the right indentation button on Visual Studio 2010 IDE.
So today I searched "auto indentation in vs " on google and the first result I got solved my problem. What it suggests is:
- Select the code you want/need to indent.
- Press Ctrl + K + F
Now don't say tab or the right indentation button would have the same effect. Because they won't. With tab/indentation button all the text selected will be pushed by 5 spaces, while Ctrl + K + F would result in proper formatting. Only the lines that need to be pushed will be pushed, the ones which are already at their proper plac would stay where they are supposed to.
Visual Studio IDE I have tried this trick on:
Visual Studio 2010