Is there global .editorconfig in Visual Studio 2017 - visual-studio

In Visual Studio 2017 we can use .editorconfig file in our project to set code style rules for the project. There is also a list of settings for Visual Studio itself presumably used when there is no editorconfig in the project. Is there a default editorconfig somewhere in Visual Studio that I can replace to set these settings rather than click through each of them?

As pointed out by #gunr2171 there is no .editorconfig file in the Visual Studio settings. However as pointed out by #Hans Passant you could work around the issue by placing an .editorconfig file in the directory where you keep your projects. Because Visual Studio looks up the directory tree to find an .editorconfig with root=true the settings will be applied even though they are outside the directory of the solution.

Visual Studio doesn't have a machine-level .editorconfig file, but it does have machine-level style settings. If you have a .editorconfig file in your solution it will override those particular settings.
From the VS 2017 release notes:
Building on Visual Studio's support for EditorConfig, we worked with the community to add .NET code style settings to the file format. This means that you can configure your team's code style conventions, check them into source control, and have violations appear live in the editor as developers are typing. You can see all the code style options in the Roslyn repo's .editorconfig or in the documentation. You can continue to configure your machine-specific code style settings in Tools > Options > Text Editor > [C#/Basic] > Code Style and these rules are overridden when an EditorConfig is present and conflicts.

Yes, you can do it!, and the best way to do it now is using the EditorConfig Language Service extension.
From the extension's description:
The EditorConfig Project helps developers define and maintain
consistent coding styles between different editors and IDEs.
Visual Studio 2017 natively supports .editorconfig files, but it
doesn't give language support for editing those files. This extension
provides that.
So, you can have default settings in VS 2017 and override them using the .editorconfig file, not only in your solution but also within your solution's projects, and you can have as many .editorconfig files as you like.
Please give it a try !

Related

Export Visual Studio's 'Code Style settings' as .editorconfig

Our team works with Visual Studio 2017 Professional.
I've been trying to unify the Code Style across the team and apparently the industry standard right now is to use .editorconfig files. Even Visual Studio in it's settings windows suggests to use that configuration file and links to a useful page on how to write an editorconfig file.
but I don't want to write all the settings that I already have configured in VS by hand. I would like a tool that exports those settings as a .editorconfig file to distribute them.
I haven't been able to find any tool to do just that so I thought on righting it myself and share it with other people like me. But apparently if go to "Tools -> Import and Export Settings..." you can't download your current Code Style settings.
Is there a way around this?
do you know any tool to convert my settings to an editorconfig file or a way to export my current Code Style settings?
Edit
I have created my own version of the .editorconfig file based on the information found in here
You can find it in my github repo
I realise this isn't much help for VS2017 users, but VS2019 has a button "Generate .editorconfig file from settings" on the Code Style options page:
This options page is available at Tools > Options > Text Editor > [C# or Basic] > Code Style > General.
I know this question is ancient but worth an answer...
The latest Visual Studio extension allows you to do this (Guide here):
Basically install the extension and right click on the solution or project (you can restrict the rules to solution/project or even folder) and click add > new EditorConfig (IntelliCode)
There are still some restrictions about what you can do in the latest releases of Visual Studio, but Visual Studio 2017 15.8 Preview 3 or higher allow you to use a new extended “Format Document” command to perform additional code cleanup for the current document.
It's a shame you can't make all your rules cause build errors, only some of the options allow this - without this, a lot of the styling options can be ignored.

How Can I Share Visual Studio 2017 Code Style and Formatting?

My team wants to share our code styling and formatting.
We've been using Resharper for this and wanted to take advantage of the new native features in VS2017! What is the best way to do this?
.editorconfig!
Visual Studio 2017 will now respect settings from a .editorconfig file if it exists on disk, up to the project root. Currently this is supported on a per-project basis, not on a solution level (I believe R# may have supported this in the solution folder).
Almost every editor in VS should support basic editorconfig options, such as:
indent_style
indent_size
tab_width
end_of_line
Additionally, some languages also provide support for language-specific style guidelines. For .NET, see here.
Specifically for C# or VB, if you've configured your settings in VS Tools-> Options, there is also an option to generate an .editorconfig file capturing those settings:
Use this extension to generate code style and formatting options that integrate with your source control to effortlessly share solution-level settings.
https://marketplace.visualstudio.com/items?itemName=SchabseSLaks.Rebracer

Intellisense C++ file with alternative extension

Hi fellow programmers,
I have a C++ file with the extension .inc that is getting included from another C++ header. My problem is that the intellisense is inactive for this file, all the text just showing up black. I am using visual studio 2015. I have looked everywhere inside visual studio with no luck.
Is there any way to activate intellisense for this file?
Thanks in advance,
Jakob.
You need to tell VS that those .inc files are in fact C++.
Go to Tools -> Options -> Text Editor -> File Extension and add your .inc:
You need to restart Studio, at least for version 2013.

Where are the default file/folder ignore rules for Visual Studio TFS stored?

When I add a solution to TFS through the Visual Studio 2013 "Add solution to source control" menu option certain (build output) files and folders are automatically ignored. I know I can create a .tfignore file to customise this behaviour, and that is not what I'm asking about. Can anyone tell me where the default Visual Studio standard exclusion list is stored?
See https://stackoverflow.com/a/43227500/117965
File is located at %LocalAppData%\Microsoft\Team Foundation\7.0\Configuration\VersionControl\
I don't think there is a list, Visual Studio just places common Binary files onto the "Excluded" tab. It has been this way since TFS 2010. I don't even think messing with the Team Project Collection's Source Control options for multiple checkouts can help.
If there is a list, I'd guess it is in the registry somewhere.

How to associate .scss files with CSS intellisense in VS2010

I'd like to be able to use IntelliSense in .scss files for speed, but I can't see a way of associating the file type.
I've tried using Mindscape Web Workbench, and found the functionality didn't meet my needs.
After a bit of research I found that you could build file extension associations in Tools>Options>Text editor>File extension, but none of the options in the Editor DDL seemed applicable for CSS.
In Visual Studio 2012, you can do the following:
Go to Tools > Options > Text editor > File Extension
Enter scss in the Extension box.
Select CSS Source Editor from the Editor box.
For Visual Studio 2010, CSS Source Editor doesn't appear to be an option. This extension appears to do what you ask for: ScssInCss.

Resources