Mahmoud ElMansy: knowledge meant to be free

Visual C# Code Snippets vs2012

This is the my first post on C# Code Snippet.
Code Snippets is a very handy feature inside Visual Studio there is of course defulat code snippets like,
“try,for,foreach,do,enum” i found them very helpful.

The cool thing is that you can create your Owen Snippet.
First : where to found visual studio snippet
“%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#”

Second :  to manage Snippet inside visual studio you can do that from “Code Snippet Manager”

CodeSnippetManager

CodeSnippetManagerScreen

Now i will create my first Snippet for JQuery

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>JQuery</Title>
      <Author>ELMansy</Author>
      <Description>
      </Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>JQready
      </Shortcut>
    </Header>
    <Snippet>
     <!--<References>
       <Reference>
         <Assembly>System.Windows.Forms.dll</Assembly>
       </Reference>
     </References>-->
      <Code_ Language="javascript">
      <![CDATA[    $$(document).ready(function () {
                  // put all your jQuery goodness in here.
               });]]>
       </Code_>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

I will illustrate the XML
part 1) SnippetType :

 <SnippetType>SurroundsWith/Expansion</SnippetType>

How visual studio will write the snippet.
Part 2) Shortcut :

 <Shortcut>JQready</Shortcut>

The shortcut to write to bring the snippet.

Part 3) Code Language=”” :

  <Code Language="javascript">

Here it is “javascript”.

Part 4) you code :

<![CDATA[ //Your Code.  ]]>