I do WinForms and Web development in Visual Studio 2010. The web developers use a tab size of four spaces, and the WinForms developers use a tab size of two.
Since I switch backwards and forwards between the two, I was wondering if there’s a quick way to do it, without having to navigate the options every single time?
There’s not a dedicated shortcut, but let’s make one!
Simply hit
Alt+F11to bring up the Macros editor and add the following code to a new module:Then save your macros and bring up the Options window from the Tools menu and choose Environment->Keyboard:
Here, you can search for commands containing ‘macros‘ and you should see your
TwoTabSpaces()andFourTabSpaces()listed.You can now assign a keyboard shortcut to these macros. In the picture above, I’ve chosen
Alt+T, Alt+2andAlt+T, Alt+4respectively (t=Tabs, 2=two spaces etc.)You can customize them as you wish, of course.