---
title: "A Very Generic .editorconfig File (Updated) - Muhammad Rehan Saeed"
description: "An .editorconfig file helps define and maintain consistent coding styles between different editors and IDEs for files with different file extensions."
canonical_url: "https://rehansaeed.com/generic-editorconfig-file/"
last_updated: "2018-07-01T00:00:00+00:00"
meta:
  author: "Muhammad Rehan Saeed"
  keywords: ".editorconfig,C#,C# 7.3,StyleCop,Visual Studio,Visual Studio Code"
  "og:description": "An .editorconfig file helps define and maintain consistent coding styles between different editors and IDEs for files with different file extensions."
  "og:image": "https://rehansaeed.com/_og/s/o_dcbf1f20879bba10.png"
  "og:image:alt": "A Very Generic .editorconfig File (Updated) - Muhammad Rehan Saeed"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "A Very Generic .editorconfig File (Updated)"
  "twitter:image": "https://rehansaeed.com/_og/s/o_dcbf1f20879bba10.png"
  "twitter:image:alt": "A Very Generic .editorconfig File (Updated) - Muhammad Rehan Saeed"
---

> Index of every page on this site: [llms.txt](https://rehansaeed.com/llms.txt)

# [A Very Generic .editorconfig File (Updated)](https://rehansaeed.com/generic-editorconfig-file/)

Posted 1 October 2017 and updated 1 July 2018 - **2 min read**

![A Very-Generic-Editorconfig-File](https://rehansaeed.com/_ipx/f_png&s_2560x1440/images/hero/A-Very-Generic-Editorconfig-File-1366x768.png)

# Link to this sectionWhat is a .editorconfig File?

An `.editorconfig` file helps developers define and maintain consistent coding styles between different editors and IDEs for files with different file extensions. These configuration files are easily readable and they work nicely with version control systems. An `.editorconfig` file defines various settings per file extension such as charsets and tabs vs spaces.

[Scott Hanselman](https://www.hanselman.com/blog/TabsVsSpacesAPeacefulResolutionWithEditorConfigInVisualStudioPlusNETExtensions.aspx) recently wrote a blog post about this file. You can also find out more from the official docs at [editorconfig.org](http://editorconfig.org/) and the [Visual Studio Docs](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference) which I recommend you read.

# Link to this sectionA Very Generic .editorconfig

I wrote a generic [.editorconfig](https://github.com/RehanSaeed/EditorConfig/blob/main/.editorconfig) file supporting the following file types:

- C# - .cs, .csx, .cake
- Visual Basic - .vb
- Script - .sh, .ps1, .psm1, .bat, .cmd
- XML - .xml, .config, .props, .targets, .nuspec, .resx, .ruleset
- JSON - .json, .json5
- YAML - .yml, .yaml
- HTML - .htm, .html
- JavaScript - .js, .ts, .tsx, .vue
- CSS - .css, .sass, .scss, .less
- SVG - .svg
- Markdown - .md
- Visual Studio - .sln, .csproj, .vbproj, .vcxproj, .vcxproj.filters, .proj, .projitems, .shproj
- Makefile

Extensive code style settings for C# and VB.NET have been defined that require the latest C# features to be used. In addition, it sets various more advanced C# style settings. All C# related code styles are consistent with [StyleCop's](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) default styles. You can find our more about the C# code style settings from the official [docs](https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference) and also in [Kent Boogaart's](http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers) blog post.

# Link to this sectionHow do I use It?

All you have to do is drop it into the root of your project. Then any time you open a file in Visual Studio, the `.editorconfig` file settings will be used to help format the document and also raise warnings if your code style and formatting does not conform.

For Visual Studio Code, you can install the [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) extension to get support.

# Link to this sectionExciting July 2018 Update

I noticed that Microsoft silently released several new C# code style settings. I'm not sure when they were released but they're available in the current Visual Studio 15.7 update. The majority of them are to enforce the use of newer C# 7.3 syntax. I updated my generic `.editorconfig` file to add these new settings with C# 7.3 as the default.

Microsoft also updated their documentation for `.editorconfig` settings pertaining to .NET, so I added links to the docs site, so it's easy to see what each setting does and change it, if it's not to your liking. I've also included a undocumented dozen settings. There is an [open issue](https://github.com/MicrosoftDocs/visualstudio-docs/issues/1070) on GitHub to get them documented, so it's easy to see what they do.

In addition, while I was working on this, I added support for a few more file extensions, including `yaml` (`yml` was already there), `json5` (If you haven't heard of `json5`, [check it out](https://json5.org/)), `cmd` and `bat` (If you haven't switched to PowerShell yet, what are you waiting for).

Finally, Microsoft [announced last week](https://blogs.msdn.microsoft.com/visualstudio/2018/06/26/visual-studio-2017-version-15-8-preview-3/) that the Visual Studio 15.8 update which is currently being released as preview 3 will automatically fix errors when you format the document using the `CTRL+K` followed by `CTRL+D` shortcut. This is huge! It means that you can drop a `.editorconfig` file in an existing codebase and with a few clicks or keyboard shortcuts (if that's how you roll) you can clean up your code base to use the latest C# 7.3 features and a code style that suits you.

## Web Mentions

[What's this?](https://en.wikipedia.org/wiki/Webmention)

### 0 Linked

### 0 Replies

## GitHub Comments

### 2 Comments

[Comment on GitHub](https://github.com/RehanSaeed/rehansaeed.github.io/issues/77)

[![RehanSaeed](https://avatars.githubusercontent.com/u/2270364?v=4)](https://github.com/RehanSaeed)

### [RehanSaeed](https://github.com/RehanSaeed)

Owner

12 May 2020

[![Elsie Vasquez](https://camo.githubusercontent.com/03323b94b81b501b29d886d10bade41a4bcbf62e66d6554aef91599427b551b5/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f66343737653066376464306334383732613332333764346632663664313431623f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/03323b94b81b501b29d886d10bade41a4bcbf62e66d6554aef91599427b551b5/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f66343737653066376464306334383732613332333764346632663664313431623f733d393626643d6d6d26723d67) **Elsie Vasquez** commented on **2018-07-01 22:58:07**

Are rules marked as "error" expected to cause a compile time error if violated?

[![RehanSaeed](https://avatars.githubusercontent.com/u/2270364?v=4)](https://github.com/RehanSaeed)

### [RehanSaeed](https://github.com/RehanSaeed)

Owner

12 May 2020

[![Muhammad Rehan Saeed](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67) **[Muhammad Rehan Saeed](https://rehansaeed.com/)** commented on **2018-07-02 09:00:02**

> Are rules marked as "error" expected to cause a compile time error if violated?

Yes!

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://rehansaeed.com/#website","@type":"WebSite","description":"Software Developer at Microsoft, YouTuber, Open Source Contributor and Blogger","inLanguage":"en-GB","name":"Muhammad Rehan Saeed","url":"https://rehansaeed.com/","author":{"@id":"https://rehansaeed.com/#identity"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://rehansaeed.com/?search={search_term_string}"},"query-input":"required name=search_term_string"}],"publisher":{"@id":"https://rehansaeed.com/#publisher"}},{"@id":"https://rehansaeed.com/generic-editorconfig-file/#webpage","@type":"WebPage","dateModified":"2018-07-01T00:00:00+00:00","datePublished":"2017-10-01T00:00:00+00:00","description":"An .editorconfig file helps define and maintain consistent coding styles between different editors and IDEs for files with different file extensions.","name":"A Very Generic .editorconfig File (Updated)","url":"https://rehansaeed.com/generic-editorconfig-file/","breadcrumb":{"@id":"https://rehansaeed.com/generic-editorconfig-file/#breadcrumb"},"isPartOf":{"@id":"https://rehansaeed.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://rehansaeed.com/generic-editorconfig-file/"]}]},{"@id":"https://rehansaeed.com/#identity","@type":"Person","name":"Muhammad Rehan Saeed","url":"https://rehansaeed.com/about/","image":{"@id":"https://rehansaeed.com/#/schema/image/1"},"sameAs":["https://github.com/RehanSaeed","https://www.linkedin.com/in/muhammad-rehan-saeed","https://stackoverflow.com/users/1212017/muhammad-rehan-saeed","https://www.youtube.com/c/MuhammadRehanSaeed","https://www.twitch.tv/rehansaeeduk"]},{"@id":"https://rehansaeed.com/#publisher","@type":"Organization","logo":"https://rehansaeed.com/images/schema/Publisher-600x60.png","name":"Muhammad Rehan Saeed","url":"https://rehansaeed.com"},{"@id":"https://rehansaeed.com/generic-editorconfig-file/#article","@type":"Article","dateModified":"2018-07-01T00:00:00+00:00","datePublished":"2017-10-01T00:00:00+00:00","description":"An .editorconfig file helps define and maintain consistent coding styles between different editors and IDEs for files with different file extensions.","headline":"A Very Generic .editorconfig File (Updated)","inLanguage":"en-GB","url":"https://rehansaeed.com/generic-editorconfig-file/","author":{"@id":"https://rehansaeed.com/#identity"},"image":[{"@type":"ImageObject","url":"https://rehansaeed.com/images/hero/A-Very-Generic-Editorconfig-File-1366x768.png","caption":"A Very-Generic-Editorconfig-File","width":"1366","height":"768"}],"isPartOf":{"@id":"https://rehansaeed.com/generic-editorconfig-file/#webpage"},"keywords":[".editorconfig","C#","C# 7.3","StyleCop","Visual Studio","Visual Studio Code"],"mainEntityOfPage":{"@id":"https://rehansaeed.com/generic-editorconfig-file/#webpage"},"publisher":{"@id":"https://rehansaeed.com/#publisher"}},{"@id":"https://rehansaeed.com/generic-editorconfig-file/#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Blog","item":"https://rehansaeed.com/","position":1},{"@type":"ListItem","name":"A Very Generic .editorconfig File (Updated)","item":"https://rehansaeed.com/generic-editorconfig-file/","position":2}]},{"@id":"https://rehansaeed.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://rehansaeed.com/images/author/Muhammad-Rehan-Saeed/Logo-512x512.png","inLanguage":"en-GB","url":"https://rehansaeed.com/images/author/Muhammad-Rehan-Saeed/Logo-512x512.png"}]}
```

## Sitemap

See the full [sitemap](https://rehansaeed.com/sitemap.md) for all pages.
