Skip to content

Instantly share code, notes, and snippets.

@schmich
Last active July 8, 2022 11:34
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmich/45ab9181ab83fb74deca to your computer and use it in GitHub Desktop.
Save schmich/45ab9181ab83fb74deca to your computer and use it in GitHub Desktop.
Visual Studio snippet to insert Debug.WriteLine with dw
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>dw</Title>
<Shortcut>dw</Shortcut>
<Description>Code snippet for Debug.WriteLine</Description>
<Author>Chris Schmich</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>System.Diagnostics</Namespace>
</Import>
</Imports>
<Declarations>
<Literal Editable="false">
<ID>Debug</ID>
<Function>SimpleTypeName(Debug)</Function>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[$Debug$.WriteLine($end$);]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
@schmich
Copy link
Author

schmich commented Oct 31, 2015

Setup

  • Save the snippet file locally
  • In VS, Ctrl+K Ctrl+B or Tools > Code Snippets Manager...
  • Import..., browse to snippet, select it, hit Finish
  • In the editor, type dw <Tab> <Tab> to insert the Debug.WriteLine snippet
  • This will also add a System.Diagnostics import to the source file

@adravi
Copy link

adravi commented Aug 11, 2018

It works for me in VS 2015 and 2017. Thanks mate!

@tngo8
Copy link

tngo8 commented Oct 11, 2018

Thank you, works so well

@H0neyCake
Copy link

Great work, thx.

@gt4dev
Copy link

gt4dev commented Mar 12, 2020

On my VS2019 it doesn't work.

@mathaou
Copy link

mathaou commented Mar 18, 2020

On my VS2019 it doesn't work.

Works fine for me. Save it in a .snippet file and select to import it to My Snippets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment