Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Great Visual Studio snippets (Read 3609 times)
Fex
Junior Member
**
Offline


Posts: 10
Joined: Jul 21st, 2014
Great Visual Studio snippets
Jun 2nd, 2015 at 8:21pm
Print Post  
Hi there - 


Got some awesome Visual Studio snippets to share? Post them here. The rules are simple, pick a unique snippet name and post the entire content in a code block. This makes installation easy because you can simply copy the entire content in a file in this folder:

Documents\Visual Studio 2013\Code Snippets\Visual C++\My Code Snippets

For those who don't know what these are:

Quote:
A code snippet is a block of reusable code that you can insert where you need it in your code. Snippets can be simple or more complex—for example, blocks such as try-finally and if-else are commonly used, but you could also use snippets to insert entire classes or methods.


To use a snippet, simply type in the shortcut and press TAB. If the snippet has arguments, cycle through them with TAB and insert the snippet with ENTER.

Here's a few that I made last night:

type "slb", tab and insert a Serial.begin()
Code
Select All
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>slb</Title>
      <Shortcut>slb</Shortcut>
      <Description>Code snippet inserts a Serial.begin()</Description>
      <Author>Fex</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>baudRate</ID>
          <ToolTip>Baud Rate</ToolTip>
          <Default>9600</Default>
        </Literal>
      </Declarations>
      <Code Language="cpp">
        <![CDATA[Serial.begin($baudRate$);$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
 



type "sla", tab and insert a Serial.available()
Code
Select All
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>sla</Title>
      <Shortcut>sla</Shortcut>
      <Description>Code snippet that inserts a Serial.available()</Description>
      <Author>Fex</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="cpp">
        <![CDATA[Serial.available();$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
 



type "slpl", tab and insert a Serial.println()
Code
Select All
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>slpl</Title>
      <Shortcut>slpl</Shortcut>
      <Description>Code snippet that inserts a Serial.println</Description>
      <Author>Fex</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>string</ID>
          <ToolTip>String</ToolTip>
          <Default>""</Default>
        </Literal>
      </Declarations>
      <Code Language="cpp">
        <![CDATA[Serial.println($string$);$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
 



If you don't use snippets yet also take a look at some of the build-in snippets. For example, you can type "if", tab to insert a full if-statement with parenthesis and accolades. 

I'm looking forward to your snippets.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Great Visual Studio snippets
Reply #1 - Jun 2nd, 2015 at 8:31pm
Print Post  
That's great. I had been meaning to add some facility and documentation but this is a great idea thanks.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint