Visual Studio Code naming convention

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:
code suggestion without 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:

dotnet_naming_rule.private_members_with_underscore.symbols  = private_fields    = 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.

code suggestion with underscore - naming convention applied

As you can see the naming convention is applied to the code suggestion. Now I’m more productive :mrgreen:

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , . Bookmark the permalink.

1 Response to Visual Studio Code naming convention

  1. Ade says:

    Many thanks Eric for the information.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.