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?
press ctrl + shift + P and type "Create snippet" on the command palette and press ENTER. snippet name, type snippet shortcut and then type snippet description. You are now good to go.
To create or edit your own snippets, select User Snippets under File > Preferences (Code > Preferences on macOS), and then select the language (by language identifier) for which the snippets should appear, or the New Global Snippets file option if they should appear for all languages.
Depending on your plaform, your user snippets file is located here: Windows %APPDATA%\Code\User\snippets\(language). json.
Type part of a snippet, press enter , and the snippet unfolds. Alternatively, press Ctrl + Space (Windows, Linux) or Cmd + Space (macOS) to activate snippets from within the editor.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With