Ho creato uno snippet personalizzato da utilizzare in Visual Studio. In VS2013, ha funzionato come previsto, ma da quando lo ha usato in VS2015 (Community Edition) è stato inserito un nuovo extra prima del codice (a destra quando premo tab/invio la seconda volta).Snippet inserisce newline extra in VS2015
Questo sembra essere solo un problema con lo snippet personalizzato (quelli integrati funzionano bene). Qualcuno sa che cosa potrebbe causare questo? È molto fastidioso
Come nota a margine, ciò accade solo se sto attivando lo snippet su una riga di codice vuota. Se lo faccio dopo il codice esistente, il newline non è inserito. Sfortunatamente, lo snippet è una dichiarazione, quindi questo non aiuta molto.
Ecco il frammento di codice, copiato quasi interamente dal campione VS:
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/CodeSnippet">
<CodeSnippet Format="1.0.0">
<!-- The header contains information describing the snippet. -->
<Header>
<!-- The Title of the snippet, this will be shown in the snippets manager. -->
<Title>Insert Field Add</Title>
<!-- The description of the snippet. -->
<Description>Inserts a basic field add for a DataObject</Description>
<!-- The author of the snippet. -->
<Author>Thomas Price</Author>
<!-- The set of characters that must be keyed in to insert the snippet. -->
<Shortcut>fadd</Shortcut>
<!-- The set of snippet types we're dealing with - either Expansion or -->
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<!-- Now we have the snippet itself. -->
<Snippet>
<!-- Create any declarations that we use in the snippet. -->
<Declarations>
<Literal>
<ID>FieldName</ID>
<ToolTip>Enter the field name</ToolTip>
<Default>field</Default>
</Literal>
</Declarations>
<!-- Sepecify the code language and the actual snippet content. -->
<Code Language="CSharp" Kind="any">
<![CDATA[$FieldName$ = fields.add($FieldName$, "$FieldName$");]]>
</Code>
</Snippet>
</CodeSnippet>
Possibile duplicato del [codice Visual Studio frammenti di linea extra] (https://stackoverflow.com/questions/33297458/visual-studio-code-snippets-extra-line) –