繁体   English   中英

Snippet在VS2015中插入了额外的换行符

[英]Snippet inserts extra newline in VS2015

我已经制作了一个在Visual Studio中使用的自定义代码段。 在VS2013中,它按预期工作,但自从在VS2015(社区版)中使用它以来,它在代码之前插入了一个额外的换行符(当我按Tab键/第二次输入时)。

这似乎只是自定义代码段的问题(内置的工作正常)。 有人知道是什么原因引起的吗? 这很烦人。

作为旁注,只有在我在一行空代码上激活代码片段时才会发生这种情况。 如果我在现有代码之后执行此操作,则不会插入换行符。 不幸的是,该片段是一个声明,所以这没有多大帮助。

这是几乎完全从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>

您可以通过在代码段文本中的某处放置$ end $来阻止前面的换行符。 例:

<![CDATA[$FieldName$ = fields.add($FieldName$, "$FieldName$");$end$]]>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM