Created
August 22, 2016 20:47
-
-
Save madskristensen/06d435aad1542dab57949af106369b92 to your computer and use it in GitHub Desktop.
How to set basic settings to any language in VS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.Composition; | |
using Microsoft.VisualStudio.Text.Editor; | |
using Microsoft.VisualStudio.Utilities; | |
namespace YamlSpacesFix | |
{ | |
[Export(typeof(IWpfTextViewCreationListener))] | |
[ContentType(ContentType)] | |
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)] | |
public class YamlCreationListener : IWpfTextViewCreationListener | |
{ | |
public const string ContentType = "YAML"; | |
[Export(typeof(ContentTypeDefinition))] | |
[Name(ContentType), BaseDefinition("text")] | |
public ContentTypeDefinition MarkdownContentType { get; set; } | |
[Export(typeof(FileExtensionToContentTypeDefinition))] | |
[FileExtension(".yml"), ContentType(ContentType)] | |
public FileExtensionToContentTypeDefinition CsonFileExtension { get; set; } | |
public void TextViewCreated(IWpfTextView textView) | |
{ | |
// Required. Forces spaces instead of tab when hitting the TAB key | |
textView.Options.SetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId, true); | |
// Optional. Makes indentation size 2. YAML should work with any indentation size | |
textView.Options.SetOptionValue(DefaultOptions.IndentSizeOptionId, 2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment