custom code snippets in intellisense

后端 未结 3 1396
梦毁少年i
梦毁少年i 2021-01-04 12:06

I\'ve started exporting some of my frequently used blocks of code to custom snippets. Is there a way to get these to show up in IntelliSense and not have to use the snippet

相关标签:
3条回答
  • 2021-01-04 12:27

    You need to set the ShortCut property like <Shortcut>slpropdp</Shortcut>. The best way to learn editing this, just check any of the already existing codesnippets. By, going to Tools -> Code snippet manager. Select any code snippet, the location of the code snippet will be available at the top location bar

    0 讨论(0)
  • 2021-01-04 12:27

    If you are still not seeing the shortcut, but you have ReSharper then check in Resharper > Options > IntelliSense > General. If you have ReSharper radio button selected, then your intellisense created in VS [shortcut] will not appear. Change that to Visual Studio or alternatively create intellisense in ReSharper

    0 讨论(0)
  • 2021-01-04 12:38

    Here is a brief description on how to create your own Snippets in Visual Studio with the 'shortcut' tag.

    using a Code Snippet for INotifyPropertyChanged

    This is the tag that is required to get the shortcut functionality.

     <Shortcut>switch</Shortcut> 
    

    Here is a snippet for switch which is inbuilt into VS

    <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>switch</Title> 
            <Shortcut>switch</Shortcut> 
            <Description>Code snippet for switch statement</Description> 
            <Author>Microsoft Corporation</Author> 
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType> 
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>expression</ID> 
                    <ToolTip>Expression to switch on</ToolTip> 
                    <Default>switch_on</Default> 
                </Literal>
                <Literal Editable="false">
                    <ID>cases</ID> 
                    <Function>GenerateSwitchCases($expression$)</Function> 
                    <Default>default:</Default> 
                </Literal>
            </Declarations>
            <Code Language="csharp">
                <![CDATA[
                    switch ($expression$)
                    {
                        $cases$
                    }
                ]]>
            </Code>
        </Snippet>
    </CodeSnippet>
    

    0 讨论(0)
提交回复
热议问题