Visual Studio代码片段多了一行 [英] Visual Studio code snippets extra line

查看:113
本文介绍了Visual Studio代码片段多了一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio(社区2015)中使用代码片段来自动执行行Debug.LogFormat("");.该代码段正常运行,但是在开始时添加了一个额外的空行(输入),因此,将该代码段与log tab tab 一起使用将产生以下代码:

I am using a code snippet inside Visual Studio (Community 2015) to automate the line Debug.LogFormat("");. The snippet is working but it adds a extra empty line (enter) at the start so using the snippet with logtabtab will result in the following code:

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

代替

Debug.LogFormat("");

这是我使用的代码段的XML:

Here is the XML of the snippet I use:

<?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>

推荐答案

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

I can fix the problem by placing a $end$ in the Code element. I don't know the root cause. Just have a try.

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

此处中查看有关Code元素的更多文档.

See more document about Code element here.

这篇关于Visual Studio代码片段多了一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆