I’ve been using the Visual Studio 2017 naming convention to generate code the way I like. Now I want to apply this behaviour to Visual Studio Code on my MacBook. Private fields should start with underscore:
First install EditorConfig from the marketplace. This will add the “generate editorconfig” to the Explorer sidebar’s context menu. You can create the file by hand, but this is easier.
Create the .editorconfig file in the root of your project from the context menu in the Explorer sidebar.
Now add the following lines to the .editorconfig file you’ve just created (source: https://stackoverflow.com/a/49428349)
[*.{cs,vb}] dotnet_naming_rule.private_members_with_underscore.symbols = private_fields dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore dotnet_naming_rule.private_members_with_underscore.severity = suggestion dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private dotnet_naming_style.prefix_underscore.capitalization = camel_case dotnet_naming_style.prefix_underscore.required_prefix = _
Restart Visual Studio Code.
As you can see the naming convention is applied to the code suggestion. Now I’m more productive
Many thanks Eric for the information.