VS 2013 Community - Creating Code Snippets

I follow this: https://msdn.microsoft.com/en-us/library/ms165394.aspx?f=255&MSPPError=-2147217396

I'm trying to make a code snippet to speed up my coding (#procrastination)

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Class layout for PlatformGameEngine</Title>
    </Header>
    <Snippet>
      <Code Language="C++">
        <![CDATA[
          namespace PlatformGameEngine
          {
              class _
              {
              // Methods
              public:
                  _();
                  ~_();
              private:

              // Properties
              public:

              private:

              }
          }
        ]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

1. Why is the following code fragment not working?

Selected file fragments are invalid.

2 .. How can I replace the _ part with the ability to insert fields and fill them?

+4
source share
2 answers

An example was found from the Visual Studio fragment manager:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Snippets\1033\Visual C++

I see from the class example, I had the missing material:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Class layout for PlatformGameEngine</Title>
      <Shortcut>gameengineclass</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>name</ID>
          <ToolTip>Class name</ToolTip>
          <Default>MyClass</Default>
        </Literal>
      </Declarations>
      <Code Language="cpp">
        <![CDATA[#pragma once

        // Boiler plate includes



        // Project specific includes



        // Namespaces



        namespace PlatformGameEngine
        {
            class $name$
            {
            // Methods
            public:
                          $name$();
                          ~$name$();
            private:

            // Properties
            public:

            private:

            }
        }]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
  • Deleted distance after CDATA [...
  • node
  • ,

:

  • , , , ... , .
  • ctrl+k, h, ctrl, . , .
  • , ... #rely?
  • ... : $classname$::$classname, <Default>MyClass</Default> ... , ,
+3

@Jimmyt1988 , . :

  • <Code Language="C++">
  • <Code Language="Visual C++">
  • <Code Language="VisualC++">

, :

  • <Code Language="cpp">

Visual Studio 2015.

0

Source: https://habr.com/ru/post/1585001/


All Articles