VS2010: How to use the prop snippet?
Excuse my ignorance. I just saw Scott Hanselman's video on MVC 3 where he typed prop, which I had not seen before. I tried it but I am doing something wrong. LOL
I type prop
which expands to
public TYPE Type1 { get; set; }
and highlights TYPE. I type the data type which replaces the word TYPE, hit tab to move to the Type1 placeholder and start typing, but it doesn't replace Type1, just types in开发者_如何学C front of it.
What's the correct way to move between TYPE and Type1 so that it highlights and replaces these placeholders as you type, and to move to the next line?
All the stuff I found on the Internet just said it creates this for you, but didn't say how to use it.
Press Tab twice after replacing TYPE, thats will be delete word Type1.
Press TAB
to expand the snippet, TAB
to loop through all the placeholders, and ENTER
to commit the snippet once finished.
Note: C# and HTML/ASP.NET/JScript snippets all behave approximately the same. VB snippets behave slightly different in that pressing ENTER
does not commit the snippet (which is very annoying IMHO).
The 'prop' snippet doesn't populate this way in Visual Studio 2010- the prop snippet only creates a manually editable template. you can, however, use Auto-Implemented Properties; this is (arguably) a better riff on the same concept:
-First, type:
[Public | Private | Etc] Property MyPropName as [New] MyPropType [= DefaultVal]
VS will (invisibly) implement standard Get/Set functionality automatically
To expand the Get/Set code, just go to the blank line following the property declaration, and type:
G [Enter] | S [Enter]
to generate explicit read-only get or write-only set code (respectively)
SOURCE
Just type prop then press TAB twice. That's all.
精彩评论