【问题标题】:Visual Studio code snippets extra lineVisual Studio 代码片段额外行
【发布时间】:2015-10-23 16:43:52
【问题描述】:

我在 Visual Studio (Community 2015) 中使用代码 sn-p 来自动化行 Debug.LogFormat("");。 sn-p 正在工作,但它在开始时添加了一个额外的空行(输入),因此使用带有 logtabtab 的 sn-p 将导致以下结果代码:

// blank line
Debug.LogFormat("");

而不是

Debug.LogFormat("");

这是我使用的 sn-p 的 XML:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>Unity LogFormat</Title>
            <Author>Faas</Author>
            <Shortcut>log</Shortcut>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>  
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>Message</ID>
                    <ToolTip>Message</ToolTip>
                    <Default></Default>
                </Literal>           
            </Declarations>
            <Code Language="CSharp"><![CDATA[Debug.LogFormat("$Message$");]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

【问题讨论】:

    标签: visual-studio visual-studio-2015 code-snippets


    【解决方案1】:

    我可以通过在Code 元素中放置$end$ 来解决此问题。我不知道根本原因。试一试。

    <Code Language="csharp"><![CDATA[Debug.LogFormat("$Message$");$end$]]>
    

    查看更多关于Code元素here的文档。

    【讨论】:

      猜你喜欢
      • 2020-09-07
      • 2016-11-17
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 2016-02-20
      • 2021-11-11
      • 1970-01-01
      相关资源
      最近更新 更多