Home > Net >  Visual Studio cw snippet works, but then doesn't when I do it again
Visual Studio cw snippet works, but then doesn't when I do it again

Time:01-24

I type 'cw' press tab twice and bam 'Console.WriteLine()' appears. I then press enter and move to another line type 'cw' press tab twice and wtf 'cw.WriteLine()' appears.

enter image description here

I tried throwing my computer out the window but remembered that I need it.

CodePudding user response:

Reinstall and its fixed! IF thats not an option, force update or check integrity. It has happened to me before but just opening and closing did it for me

You might also have some extension or plugin installed that overrides the default behavior

CodePudding user response:

First, please check whether the version of your VS2022 is the latest version, I am currently using VS community 17.4.4, and the code snippets shortcut 'cw' works fine on my side.

1, So first, please make sure you are based on the latest version of VS2022:

enter image description here

2, Second, you can try to reset the environment settings and enter image description here

enter image description here

enter image description here

enter image description here

turn off synchronized settings on a particular computer:

enter image description here]enter image description here

3, And please check whether other snippets have this problem, if not, I suggest you to create your own code snippets, import it and then try again.

Creat a file named xxx.snippet:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>xxx</Title>
            <Shortcut>xxx</Shortcut>
            <Description>Code snippet for Console.WriteLine</Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal Editable="false">
                    <ID>SystemConsole</ID>
                    <Function>SimpleTypeName(global::System.Console)</Function>
                </Literal>
            </Declarations>
            <Code Language="csharp"><![CDATA[$SystemConsole$.WriteLine($end$);]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

After that, import this code snippets:

enter image description here

enter image description here

After that, write xxx and double press Tab.

  • Related