how to make snipet ?

  • Thread starter Thread starter Jarod
  • Start date Start date
J

Jarod

Hey
I would like customize a little existing snippet in VS. Let's say there is
snippet prop that works as a property. And it works pretty nice, but I would
like it to automatically insert property name based on private field. So if
the private field is named _id the property should be ID. I believe it's not
much work but it will make my development a little faster. Will it be hard
to change this behaviour ?
Jarod
 
AFAIK, that is not possible, a snippet is just an xml file and you
cannot provide custom logic

that said, the snippet you mentioned is physically located at

C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual
C#\prop.snippet

and should you want to change it, edit a copy and save it in

C:\Documents and Settings\<username>\My Documents\Visual Studio
2005\Code Snippets\Visual C#\My Code Snippets

alternatively, use the snippet manager to setup another path
 
That snippet already exists. Just type prop in the code window and
press TAB, the property will appear and you can change the private
field variable name and the property name. I don't think you can do
what you intend with a private field that already exists.
 
Have you checked out the "Promote local variable to parameter" refactoring?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top