views:

243

answers:

2

I'm working on a couple of different things and some use tabs, some use 2 spaces for indents, another users 4 spaces for indents etc.

The option to set this in Visual Studio is in Tools->Options->Text Editor-><language>->Tabs

Is there some way to override these settings on a per solution bases?

+3  A: 

Here is one (admittedly hacky) way to achieve what you are looking for:

1) create a macro that changes the indentation (source)

 Sub Set-Indent(indent As integer)
     Dim props As EnvDTE.Properties = DTE.Properties("TextEditor", "C/C++")
     Dim ts As EnvDTE.Property = props.Item("TabSize")
     Dim ins As EnvDTE.Property = props.Item("IndentSize")
     ts.Value = indent 
     ins.Value = indent 
 End Sub

2) Hook that up with your solution loading: In the macro explorer, choose EnvironmentEvents, select SolutionEvents in the first drop-down, Opened in the second. You now have a macro that will trigger every time you open a solution. You just need to map your solutions to the required indentation.

Bahbar
Hack, yes, but it works. Thanks. For C# devs, it's DTE.Properties("TextEditor", "CSharp")
Mike Stockdale
+2  A: 

There is an interesting workaround. But it requires some attention and takes 10-20 seconds more to launch a studio. See this post for details.

zihotki