Store per-project source formatting settings with project properties
I wish it were possible to define per-project editor settings that affect formatting and writing style: tab size, use tabs/spaces, autoindent and so on.
Because, different solutions (or even projects in one solution) can have different coding styles or conventions.
Having to poke in several tabs of environment settings every time as I switch projects is a major annoyance.
Actually the formatting settings are not private user preferences; they are part of a project and should be stored in source sontrol, so that the next person that takes on the code automatically gets the proper settings.
It would very helpful to have settings across an entire Solution rather than having to repeat them in every Project, such as, Connection Strings, shared directories, email Server names, etc.
While I think it would usually be preferable to treat them style as a project property, I am not convinced that that is ideal for every project: perhaps some teams are sufficiently laid back about style to allow everyone to do their own thing. I would make it optional but default that the project settings override user preferences.
To solve this problem, I wrote Rebracer, which stores source formatting settings in an XML file with each solution.
Just install this Visual Studio extension, right-click your solution, and click Add, New Rebracer Settings File, then change options for that solution only.
David Poole commented
I can't get EditorConfig to work at all. I'm using VS 2012 it seems to have no effect. Any tips?
EditorConfig is works fine per-project or per-solution.
Its real problem is that it doesn't support source formatting settings.
Gulshanur Rahman commented
It will be useful to have per-project formatting settings, a global settings with option to override per-project settings and format according to per-project setting before pushing code to GIT or TFS.
Steve Williams commented
EditorConfig is NOT an answer for this, for two reasons:
- EditorConfig is for across IDEs, not per project or per solution.
- EditorConfig requires Visual Studio Professional or higher.
MonoDevelop does have per-project text editor settings that are stored in the project file, and is a good example of how it should be done in Visual Studio.
Christopher Bennage commented
an emerging community standard? http://editorconfig.org/
Chris Patterson commented
So like R# does with per-solution settings? I hope per-solution is what was requested as I would hate to customer per project within the same solution.
This is extremely useful, especially in workflows with source control and lots of participants. For instance, open source repos on github, where people (other than the regular contributors) are sending pull requests and the code formatting quality is affected by different IDE settings.
EditorConfig only helps for indentation settings (tabs vs. spaces); we still need the ability to change other editor settings like autoformat behavior or Sort Usings settings.
Peter Atashian commented
Yes yes yes, absolute yes!
This would be absolutely awesome.
Yes, EditorConfig is what is needed... at least, very close to it!
Jed Hunsaker commented
There's an NuGet package called EditorConfig which does just this.
Olaf van der Spek commented
I vote for auto-detection too. What if a file is edited that's not part of an opened project/solution?
Settings to trim trailing whitespace and for encoding and end of line style would be nice too.
James Tryand commented
This feature is already available within Visual Studio, and has been for a while.
Jim Christophers magnificent powershell tooling to Visual Stuido exposes this functionality.
See: http://www.youtube.com/watch?v=5d7gwoIQNpg (about 2/3 way through)
Ian William James Halliday commented
There should be settings at each level of granularity, projects, solutions, user (dropbox!). Each overrides the next.
E.g. I have my typical settings that I prefer, but I open some OSS solution with different settings, so it overrides my settings. Further within this solution one particular project is inconsistent with the rest, so it has its own settings which override the solution's settings.
Merged from another idea: It would very helpful to have settings across an entire Solution rather than having to repeat them in every Project, such as, Connection Strings, shared directories, email Server names, etc.
Working on OSS projects, this is the bane of my life.
I've always found it silly that VS treats formatting settings as a user preference, when clearly it's a per-project preference.
Eclipse does this, so VS can too. Or even should. -