Code indenting specified at project/solution level rather than global [duplicate]
Possible Duplicate:
Visual Studio, per solution indentation settings
So I have a situation where I am working on a code base from some contractors that has its code indented to 4 spaces, every other project I work with is 2 spaces.
What is my best 开发者_运维百科strategy for switching back and forth between the 2 indenting standards, Visual Studio 2010 sets this globally not at a solution level.
The Visual Studio SDK provides access to this setting: http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.package.languagepreferences.indentsize.aspx
It seems quite likely that someone's already developed an addin to manage indentation settings, maybe even listed in the Addins/Extensions Gallery, also viewable inside VS2010.
This one seems like a good fit:
Indentation Matcher Extension
This extension detects the current file's indentation settings and automatically resets the corresponding Tools->Options settings to match. It also detects mixed tabs and spaces on file load and file save, then offers options to make indentation consistent.
You could on opening an offending file (i.e. one that doesn't conform to your standard), press CTRL+K, CTRL+D
, which will reformat to the current Visual Studio settings. Not perfect, but might reduce the 'pain'. You might even be able to automate this through Visual Studio.
In addition, you would have to ask your contractors to change there standard; might be difficult to convince them (I know I wouldn't!).
Have you tried creating two Custom Editor settings files, and loading the relevant one when required?
Also, as mentioned in the comments, many source code Diff tools can ignore whitespace, so converting files when opened should not cause check-in differences.
精彩评论