Visual Studio + Razor: "Surround with ..." Snippets

I am trying to use these awesome VS "Surround With" snippets with VS, but they are not working properly. Say I have a code:

<p>Success!</p> 

If I select this code and select the ASP.NET MVC 4 / ifcs4 snippet , I would expect my code to be as follows:

 @if (true) { <p>Success!</p> } 

But instead, it becomes:

 <% if (true) { %> <p>Success!</p> <% } %> 

These <% tags are not even used in Razor syntax, so why are they there? Can't I make it work as expected?

+5
source share
1 answer

I think this is just oversight of part of Microsoft.

I found the path to the fragments by selecting Tools -> Code Snippets Manager, the selected HTML as the language, and choosing ifcs4. Path to fragment (for VS 2013):

C: \ Program Files (x86) \ Microsoft ASP.NET \ ASP.NET MVC 4 \ Visual Studio 2013 \ Snippets \ HTML \ 1033 \ ASP.NET MVC 4 \ ifcs.snippet

I updated the file using the Razor-style if it worked perfectly even without reloading the project.

+6
source

All Articles