{"id":7196,"date":"2020-07-11T15:07:18","date_gmt":"2020-07-11T15:07:18","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=7196"},"modified":"2020-07-11T15:07:18","modified_gmt":"2020-07-11T15:07:18","slug":"editorconfig","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/editorconfig\/","title":{"rendered":"Editorconfig"},"content":{"rendered":"<p>When we&#8217;re collaborating with other developers, whether you&#8217;re writing JavaScript, C~ or whatever, it&#8217;s useful (some may say essential) to create a coding style that all developers adhere to. After all, one of the aims of collaboration is that you shouldn&#8217;t really be able to tell who wrote what code just by the code style.<\/p>\n<p>With web development it&#8217;s not unusual to enforce code style etc. with eslint &#038; prettier but this is often shown as a warning when things are working against the style or in some cases, these changes are only applied upon committing the source code. It&#8217;s be much better if we could have the editor automatically work the same, for things like indent styles (for example).<\/p>\n<p>This is where the .editorconfig comes in. A file you should commit with your source code and is supported by Visual Code, Visual Studio, JetBrains IDE&#8217;s etc.<\/p>\n<p>I&#8217;ll be honest, the main reason I use the .editorconfig is to configure my editors to use the same indent_size. Here&#8217;s a basic .editorconfig file<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nroot=true\r\n\r\n&#x5B;*]\r\nindent_size = 2\r\nend_of_line = lf\r\n<\/pre>\n<p>Visual Code has an extension available named <em>EditorConfig<\/em> which can be used to generate a bare bones .editorconfig for you. Visual Studio has a file template, just add a new file to your project using the Add | New Item&#8230; context menu and search for editorconfig. Selecting the editorconfig (.NET) will populate the .editorconfig with lots of options set for various .NET languages.<\/p>\n<p>If you have an .editorconfig file in the root of your project it will be applied to all sub-folders unless overridden by another .editorconfig in one or more of these folders.<\/p>\n<p>If you want to override some, but not all options within the root .editorconfig then just put those additions\/changes in the file and ensure <\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nroot = true\r\n<\/pre>\n<p>exists in the root level file. <\/p>\n<p>As you&#8217;d expect the .editorconfig is read top to bottom, hence if you have a duplicate key later on in the file this will override any previous value.<\/p>\n<p><strong>References<\/strong><\/p>\n<p><a href=\"https:\/\/editorconfig.org\/\" rel=\"noopener noreferrer\" target=\"_blank\">EditorConfig<\/a><br \/>\n<a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/create-portable-custom-editor-options?view=vs-2019\" rel=\"noopener noreferrer\" target=\"_blank\">Create portable, custom editor settings with EditorConfig<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we&#8217;re collaborating with other developers, whether you&#8217;re writing JavaScript, C~ or whatever, it&#8217;s useful (some may say essential) to create a coding style that all developers adhere to. After all, one of the aims of collaboration is that you shouldn&#8217;t really be able to tell who wrote what code just by the code style. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[246,50],"tags":[],"class_list":["post-7196","post","type-post","status-publish","format-standard","hentry","category-visual-code","category-visual-studio"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=7196"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7196\/revisions"}],"predecessor-version":[{"id":8407,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7196\/revisions\/8407"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=7196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=7196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=7196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}