Saeb Amini Saeb Amini - 1 year ago 76
C# Question

How to Put Empty Literal in Code Snippet

I've slightly modified VS's

snippet. The idea is that if I want parameters or a body, I type them in, otherwise I can hit Enter twice to skip and make it parameterless:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="">
<CodeSnippet Format="1.0.0">
<Description>Code snippet for constructor</Description>
<Author>Microsoft Corporation</Author>
<Literal Editable="false">
<ToolTip>Class name</ToolTip>
<Code Language="csharp"><![CDATA[public $classname$ ($parameters$)

It works great, except it has a small nuisance in case I want parameterless:

public ProjectTask( )
{ }

Notice the extra space character
between the parentheses? I know I'm taking laziness to a whole new level here but is it possible to make that go away?

Answer Source

I just tried my exact same snippet above in VS 2015 and noticed it no longer has that problem and the generated code ends up like this:

public ProjectTask()
{ }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download