Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Great Visual Studio snippets (Read 2882 times)
Fex
Junior Member
**
Offline



Posts: 10
Great Visual Studio snippets
Jun 2nd, 2015 at 9:21pm
 
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:
<?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:
<?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:
<?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
 
Visual Micro
Administrator
*****
Offline



Posts: 10388
United Kingdom
Re: Great Visual Studio snippets
Reply #1 - Jun 2nd, 2015 at 9:31pm
 
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 Topic Print