Visual Studio code snippets extra line

爷,独闯天下 提交于 2019-12-10 13:14:30

问题


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("");

instead of

Debug.LogFormat("");

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>

回答1:


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$]]>

See more document about Code element here.



来源:https://stackoverflow.com/questions/33297458/visual-studio-code-snippets-extra-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!