Export Visual Studio's 'Code Style settings' as .editorconfig

橙三吉。 提交于 2019-12-06 17:40:36

问题


Our team works with Visual Studio 2017 Professional.

I've been trying to unify the Code Style across the team and apparently the industry standard right now is to use .editorconfig files. Even Visual Studio in it's settings windows suggests to use that configuration file and links to a useful page on how to write an editorconfig file.

but I don't want to write all the settings that I already have configured in VS by hand. I would like a tool that exports those settings as a .editorconfig file to distribute them.

I haven't been able to find any tool to do just that so I thought on righting it myself and share it with other people like me. But apparently if go to "Tools -> Import and Export Settings..." you can't download your current Code Style settings.

Is there a way around this?

do you know any tool to convert my settings to an editorconfig file or a way to export my current Code Style settings?

Edit

I have created my own version of the .editorconfig file based on the information found in here

You can find it in my github repo


回答1:


I know this question is ancient but worth an answer...

The latest Visual Studio extension allows you to do this (Guide here):

Basically install the extension and right click on the solution or project (you can restrict the rules to solution/project or even folder) and click add > new EditorConfig (IntelliCode)

There are still some restrictions about what you can do in the latest releases of Visual Studio, but Visual Studio 2017 15.8 Preview 3 or higher allow you to use a new extended “Format Document” command to perform additional code cleanup for the current document.

It's a shame you can't make all your rules cause build errors, only some of the options allow this - without this, a lot of the styling options can be ignored.




回答2:


I realise this isn't much help for VS2017 users, bur VS2019 has a button "Generate .editorconfig file from settings" on the Code Style options page.

However, if I may add a Question to an Answer - does anyone know if it's possible to import the.editorConfig file so that the options settings on the local machine then match what's in the .editorconfig file? This would be a really useful way of taking a .editorconfig file, changing the settings and re-exporting it while ensuring that any inadvertent changes that might have been made to the Code Style options since the previous export do not get exported.



来源:https://stackoverflow.com/questions/51356453/export-visual-studios-code-style-settings-as-editorconfig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!