views:

131

answers:

5

Right now when I want to use the cw snippet, I'm typing cw, tab, tab.

Is this the correct(fastest!) way of doing it? If there'd be some way of only having to hit once the tab key or any other key i'd be glad to know it.

A: 

AFAIK there's no faster way of doing this (but there's a slower one :) ):

http://msdn.microsoft.com/en-us/library/z4c5cc9b(VS.80).aspx

mamoo
A: 

Cant say I know of a faster way on the basis that you just informed me of the existance of it! +1 cheers :)

Yoda
Yes, and some are very nice. For example, try "for" + tab + tab. It will create a for loop. Then you can keep tabbing through fields to replace their values. Once you're done, press enter and you're ready to enter code. Similar with foreach and others.
Nelson
Sweet, some reading is deffinately in order after work! You may have just shaved days from my life which would otherwise be occupied with writing loops and repetitve code! :)
Yoda
It can definitely save time, but for some reason I keep forgetting to use them until after I wrote something manually. Also, I haven't done it myself, but you can create your own code snippets.
Nelson
This is a comment and not an answer :(
Oskar Kjellin
A: 

With ReSharper it is cw,tab

I'm not a big fan of R# as it slows my VS 2010 at least by 4 times.
devoured elysium
Turn off solution wide analysis.
Callum Rogers
By what I'm seeing right now, I had that option turned off. Can't imagine how slower would it been had I that feature turned on!
devoured elysium
+2  A: 

That is the fastest way. Note that the first tab is just to get rid of the IntelliSense tooltip. The second tab is the one that actually does the work. In other words, you can do cw + esc/tab/enter + tab or even c + esc + w + tab. Or you can even type cw, go somewhere else, click right after the cw then tab and it will auto complete.

That could be annoying if you do something like var cw tab.

Edit: Once you have used "cw", you can then do it a bit faster by just typing c + tab + tab. Since you last used "cw", the c will select "cw" from IntelliSense, the first tab will insert it, and the second tab will auto complete.

Nelson
A: 

Like Nelson mentioned the 1st tab is really just an escape action in this case. But I do know a way to cut down 1 keystroke. Save the following as "c.snippet" and drop it in your "..\< myDocs >\< VS20XX >\Code Snippets\Visual C#\My Code Snippets" directory:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>c</Title>
            <Shortcut>c</Shortcut>
            <Description>Code snippet for Console.WriteLine</Description>           
            <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>

Now you just have to type c, tab, tab !!

Sorax
I have other things that start with c, I dunno if that is not sometimes going to choose the others over this one.
devoured elysium
Change the value of the <Shortcut> element to any letter that is unused and you'll be able to call the snippet with that letter. Check out the following link if you have any trouble getting the snippet to show in Intellisense: http://msdn.microsoft.com/en-us/library/ms165392%28v=VS.80%29.aspx
Sorax