views:

206

answers:

4

My goal is to be able to quickly type this:

<%= %>

Can anyone suggest a way to make it easier within Visual Studio to insert the HTML code escape block. (I am not even sure the name of this piece of code!)

I realize that typing <% in the code editor will autocomplete the escape block for me, but perhaps there's an easier way to input this block?

Perhaps there is a snippet or existing key combo built into Visual Studio to accomplish this?

Even further, this would be nice as well:

<%= Html.Encode() %>
A: 

Create a snippet and use Ctrl-K, Ctrl-X(VS 2005) and that will let you select the snippet!

Rigobert Song
The "Insert Snippet" command is not available in *.aspx files. Note, not everyone has the shortcut key bound to that command.
AMissico
A: 

Check here for a detailed discussion.

Lucas B
+1  A: 

Sorry but it looks like snippets are not available for ASP.Net markup.

From this guy

Snippets are in VS2008 available for C#, XML and VB.NET files. In VS2010 that support extends to ASP.NET markup also.

Jeremy
+2  A: 

Even if you created a snippet to do that, given VS does automatic matching, wouldnt it be more keystrokes to enter the snippet, than to actually type the 3 characters?

Chad Ruppert
this is a fair point, and certainly my goal is to reduce the number of keystrokes.
p.campbell
best case you could write a macro for it and assign it to a single ctrl-key chord.... but still..
Chad Ruppert
I use this method for quite a few little chunks of code.
AMissico