Visualstudio-docs: the Editor Config file is not working on VS 2017 15.5.4

Created on 29 Jan 2018  Â·  25Comments  Â·  Source: MicrosoftDocs/visualstudio-docs

I added the .editorconfig file with basic settings but its not working in VS 2017 but works with VS Code


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

  • ID: 72f45eb4-3596-866a-2c16-ee225737d956
  • Version Independent ID: cea055e7-fe9b-95c7-6d25-086f182c01d2
  • Content
  • Content Source
  • Service: unspecified
support-request

All 25 comments

@Imranonline did you trying reloading your code files? could you share your editorconfig settings?

http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

^^ this file is saved at the solution level of a default MVC Project

The only hack what i found till now to make it work is CTRL + K +D (Format the document) and then it takes the editorconfig values automatically. So on every save i need to format it. Am i missing something ?

This does seem to be odd behavior. What type of file are you seeing the problem behavior in, @Imranonline ? (cpp, cs, txt, xml, other...)? I'm wondering if this problem is specific to a particular file format (even though your editorconfig targets all file types).

I should also say that .editorconfig conventions are only applied on new edits that you make to a file, unless you manually reformat using "Format Document". We don't auto-reformat documents on load to make them conform to the conventions in your .editorconfig file. Are you seeing the formats honored when you type new content into the file(s)?

Thanks
Mark Wilson-Thomas
Program Manager, Visual Studio IDE Team

@markw-t Yes you are correct it doesnt autoformat the content unless i do a "Format Document" but if i start a new code block it works. i was trying with .js and .cs files.
Iam open to close this issues may be it was my understanding after reading the docs.

We do have a section that talks about formatting new code vs. existing code, but I will make it more prominent. Thanks for bringing this up @Imranonline .

Thanks @Imranonline for bringing this up and confirming the behavior, and @gewarren for improving prominence of this point in the docs.

doesn't work.

root=true

[*.{cs,vb}]
dotnet_naming_rule.private_members_with_underscore.symbols = private_members
dotnet_naming_rule.private_members_with_underscore.style = underscore_prefix
dotnet_naming_rule.private_members_with_underscore.severity = suggestion

dotnet_naming_symbols.private_members.applicable_kinds = field
dotnet_naming_symbols.private_members.applicable_accessibilities = private
dotnet_naming_symbols.private_members.required_modifiers = readonly

dotnet_naming_style.underscore_prefix.capitalization = camel_case
dotnet_naming_style.underscore_prefix.required_prefix = _
dotnet_naming_style.underscore_prefix.required_suffix =
dotnet_naming_style.underscore_prefix.word_separator =
indent_style = tab
indent_size = 4

@eschneider999 thanks for the feedback. Are you saying that none of these settings are applied to your document? Have you formatted your document and/or closed/reopened it since you saved the .editorconfig file?

yes, tried close/reopen sol. Format new doc. and New line of code in violation.

I tried this on 15.6.3 and it doesn't work too - new edits are applied with editorconfig style but auto-format keep reverting to VS default settings.

@eschneider999 and @Regent can you checkout the troubleshooting section and see if it resolves your issues? It could be that you have other .editorconfig files in your directory structure, or the "Follow project coding conventions" option is off. If you are still having a problem, let us know.

I checked and I don't have any other editor configs and follow conventions is on.

@Regent this could be a bug in the language service formatter. Which code language are you working in?

@gewarren I was trying it with C#.

@Regent can you please file an issue at https://github.com/dotnet/roslyn/issues?

I'm also having the same problem.
Language: C#

Visual Studio version: 15.6.3

Editorconfig also doesn't work in this lab environment (which is MS official one).

@moerwald thanks for letting us know. Can you please log an issue at https://github.com/dotnet/roslyn/issues? I'm not sure if @regent logged one that you could upvote instead. IF you do log an issue, please add a link to this GitHub issue in it, so we know it's being tracked.

I didn't had a chance to log it, I'm afraid

@gewarren: Raised new issue -> https://github.com/dotnet/roslyn/issues/26276

@moerwald thank you! I'm going to close this issue then.

Why are we closing it if it's still broken!!!

Doesn't Microsoft fix anything anymore?
What do all you people at Microsoft Do?

@eschneider999 the product issue is being tracked by the Roslyn issue that @moerwald logged. This issues page is for the documentation, and since this is not a problem that the documentation can help with, we're tracking the bug via the Roslyn issue. If you are not using C#, then you might log a different issue for your scenario at https://github.com/dotnet/roslyn/issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaanV2 picture DaanV2  Â·  4Comments

CeciAc picture CeciAc  Â·  3Comments

wittelw picture wittelw  Â·  3Comments

ChrisMaddock picture ChrisMaddock  Â·  3Comments

Ogglas picture Ogglas  Â·  3Comments