snippet substitution

Provides intelligent code completion for SQL Server editors.

Moderators: JonathanWatts, David Atkinson, Anu Deshpande, Paul Stephenson, Michelle Taylor

snippet substitution

Postby hamishinglis » Wed Jul 04, 2012 3:12 pm

I was setting up some snippets and after clicking around on the site saw that if you enter $cursor$ that is where the cursor is left after the snippet is activated. But what i really wanted was the Date!... so i took a guess and put in $DATE$ and it worked... Is there a complete list of substitutions for snippets anywhere? why isn't this stuff with the edit snippet help page?

Also i noticed that snippets do not work if you are inside a /* */ block ? which is sad since in means you can't have a snippet for update comments like your name, the date etc.. so it always makes a consistent comment block. Is there a reason for this?
hamishinglis
 
Posts: 1
Joined: Wed Jul 04, 2012 3:04 pm
Location: United Kingdom

Postby stanori » Thu Jul 05, 2012 10:50 pm

Hello hamishinglis,

I believe the reasoning for the snippets not working in the comment block is that the parser ignores everything between the comments.

In regards to the list of additional snippets, here are some more:

code = code.Replace("$DATE$", DateTime.Now.ToShortDateString());
code = code.Replace("$TIME$", DateTime.Now.ToShortTimeString());
code = code.Replace("$USER$", Environment.UserName);
code = code.Replace("$MACHINE$", Environment.MachineName);

Best Regards,
Steve
_________________
Steve Tanori
Product Support
Red Gate Software Ltd.
866-997-0378
stanori
 
Posts: 84
Joined: Mon Apr 23, 2012 1:13 pm


Return to SQL Prompt 5

Who is online

Users browsing this forum: No registered users and 1 guest