Share via


CodeSnippet Element (IntelliSense Code Snippets)

Allows you to specify a heading and multiple IntelliSense Code Snippets, which you can insert into Visual Studio code files.

<CodeSnippets>
   <CodeSnippet>

<CodeSnippet Format="x.x.x">
    <Header>... </Header>
    <Snippet>... </Snippet>
</CodeSnippet>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute

Description

Format

Required attribute.

Specifies the schema version of the code snippet. The Format attribute must be a string in the syntax of x.x.x, where each "x" represents a numerical value of the version number. Visual Studio will ignore code snippets with Format attributes that it does not understand.

Child Elements

Element

Description

Header

Required element.

Contains general information about the code snippet. There must be exactly one Header element in a code snippet.

Snippet

Required element.

Contains the code that will be inserted by Visual Studio. There must be exactly one Snippet element in a code snippet.

Parent Elements

Element

Description

CodeSnippets

Root element of the code snippet XML schema.

Example

The following code shows a code snippet targeting version 1.0.0 of the code snippet XML schema.

<CodeSnippets xmlns="https://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <!-- Insert header information here -->
        </Header>
        <Snippet>
            <!-- Insert snippet information here -->
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

See Also

Concepts

Code Snippets Schema Reference