Visual Studio 2015 code snippet with significant spaces

For some time I had a special Visual Studio code snippet that helped inject the copyright header into my C # source files. It looks something like this:

<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <Header> <Title>File Header</Title> <Author>Me</Author> <Shortcut>header</Shortcut> <Description>Inserts a standard copyright header.</Description> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> </Header> <Snippet> <Declarations> <Literal> <ID>FileName</ID> <ToolTip>The name of the C# code file.</ToolTip> <Default>FileName</Default> </Literal> </Declarations> <Code Language="CSharp"><![CDATA[// ----------------------------------------------------------------------- // <copyright file="$FileName$.cs" company="Company Name"> // Copyright © 2011-2016 by Company Name. All rights reserved. // </copyright> // ----------------------------------------------------------------------- ]]></Code> </Snippet> </CodeSnippet> 

Important for this question are the two endpoints at the end of the CDATA block. In versions of Visual Studio until 2015, I could put my cursor at the beginning of the file, just before the first declaration using, type header+TAB , and my title will appear with an extra blank line between the last comment and first using the declaration.

Visual Studio 2015 does not seem to respect trailing spaces. When I type header+TAB , the first with the declaration appears on the same line as the last comment.

Am I looking at an error, or is there a way to customize the code snippet so that Visual Studio 2015 respects trailing spaces?

+7
c # visual-studio-2015 code-snippets
source share
1 answer

The general thing that I see when looking at the fragments that come with VS is most of all ending with the code $end$

Example from switch:

 <Code Language="csharp"><![CDATA[switch ($expression$) { $cases$ }*$end$*]]> </Code> 

Put $end$ at the end of the trailing space, for example:

 <![CDATA[// ----------------------------------------------------------------------- // <copyright file="$FileName$.cs" company="Company Name"> // Copyright © 2011-2016 by Company Name. All rights reserved. // </copyright> // ----------------------------------------------------------------------- $end$]]> 
+5
source share

All Articles