5

I'm trying to use these awesome VS "Surround With" snippets with VS, but they dont't work as expected. Say I have some code:

<p>Success!</p>

If I select this code and select the ASP.NET MVC 4 / ifcs4 snippet, I would expect that my code becomes this:

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

But instead, it becomes this:

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

These <% tags aren't even used in the Razor syntax, so why are they there? Isn't there any way I could put it to work in the expected manner?

1 Answer 1

6

I think it's just an oversight on Microsoft's part.

I found the snippets path by choosing Tools -> Code Snippets Manager, selected HTML as language and selected ifcs4. The path for the snippet is (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 with Razor-style if and it worked just fine even without reloading the project.

Sign up to request clarification or add additional context in comments.

1 Comment

Nice. Whoa, it's a shame this feature is overseen by Microsoft. It is so nice and helpful, and also so easy to fix...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.