locked
how to add a new line between using statements and namespace when using custom snippet RRS feed

  • Question

  • Now when I import namespaces it writes the using statements close to the namespace statement. I would like a line between them.

    Snippet:

    <?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>ICollection using defined entity</Title>      
    <Author>Stein Lundbeck</Author>      
    <Description>Code for implementing ICollection with defined entity</Description>      
    <Shortcut>coll</Shortcut>      
    <Keywords>        
    <Keyword>C#</Keyword>        
    <Keyword>Collection</Keyword>      
    </Keywords>    
    </Header>    
    <Snippet>      
    <Imports>        
    <Import>          
    <Namespace>System.Collections.Generic</Namespace>        
    </Import>        
    <Import>          
    <Namespace>System.Collections.ObjectModel</Namespace>        
    </Import>      
    </Imports>     
     <Declarations>        
    <Literal Editable="true">          
    <ID>Name</ID>          
    <ToolTip>Name of type</ToolTip>          
    <Default>myColl</Default>        
    </Literal>        
    <Literal Editable="true">          
    <ID>TEntity</ID>          
    <ToolTip>Type of generic object</ToolTip>          
    <Default>string</Default>        
    </Literal>      
    </Declarations>      
    <Code Language="csharp" Delimiter="$" Kind="file"><![CDATA[  ICollection<$TEntity$> $Name$ = new Collection<$TEntity$>();]]>      
    </Code>    
    </Snippet>  
    </CodeSnippet>
    </CodeSnippets>

    Output:

    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    namespace Test
    {
        class MyClass
        {
    
            ICollection<int> myColl = new Collection<int>();
    
        }  
    }
    

    As you can see, there's no line between the using statements and the namespace statement

    Friday, May 29, 2020 6:14 AM

All replies

  • Hi line beneath using statements in custom snippet,

    There are no related elements which could implement it in snippet file. So I am afraid that you can't get the results you want at this stage. 

    Please refer the elements of snippet code here: https://docs.microsoft.com/en-us/visualstudio/ide/code-snippets-schema-reference?view=vs-2019#imports-element.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, June 1, 2020 8:59 AM