Open Oblomoff opened 2 years ago
Most built-in snippets work - it appears custom snippets and built-ins with functions do not. Dirty, dirty workaround: edit a built-in snippet you don't use, and restart VS. else
and unsafe
snippets have never saved me any time, and now serve a higher purpose, along with several of their friends.
@dibarbet what are your thoughts about enabling the custom snippets and if they fall over they fall over? 😄
@NTaylorMullen totally open to trying it, simple snippets should work just fine, however I know of a couple scenarios that will for sure not work. There is some cleanup required so we can identify and log when we're in one of those unsupported scenarios.
Ah one thing we'll also want to do - switch the client side to use the async wait indicator so that we do not need to specify all the custom snippet keywords upfront. Then tab would just trigger the async wait and let the server decide if it has something.
Thanks for the details, I'll park this for now to gauge interest. For folks seeing this message be sure to upvote the original report.
@NTaylorMullen It is a big mistake to estimate interest by the number of votes. Because if a young programmer sees that there are no snippets in the editor in 2022 (!) then he will not vote, he will simply switch to another platform, not .NET. Snippets are not a backlog, snippets are a must have. The modern IT industry is not democracy, it is competition.
@NTaylorMullen It is a big mistake to estimate interest by the number of votes. Because if a young programmer sees that there are no snippets in the editor in 2022 (!) then he will not vote, he will simply switch to another platform, not .NET. Snippets are not a backlog, snippets are a must have. The modern IT industry is not democracy, it is competition.
@Oblomoff I hear you and FWIW I'm also a custom snippets user 😁
To be totally transparent let me share some more info. According to our telemetry, custom snippets usage was incredddddddiiiibbblllyy rare and in order to warrant revitalizing the tech I'm trying to capture additional data. Ultimately I'm trying to build a case to bring them back and right now the data we have indicates we shouldn't. Therefore I'm trying to give this every chance it has to make the cut!
Now all that said there has been many conversations about reworking the snippet system to make them a far better experience than they've ever been (to increase usage), which is exciting! However, that's a bit longer out in the VS journey but it's definitely top of mind.
Hope this info helps
If you want to stay with VS, the workaround solution is to use the legacy editor: stackoverflow
Fyi @ryzngard
I wish GitHub had a way to merge issues, because this and https://github.com/dotnet/razor/issues/4331 both have good comments and votes.
@NTaylorMullen I've used VS since the beginning and only recently discovered Snippets. Probably glossed over them 1000 times at least! It's a great feature, definitely worth using, but VS has so many buried capabilities that I just wasn't seeing them. I'm tempted to say they should be promoted more, but, there's like 100 other features also worth promoting. Ugh.
And (eventually) if some sort of AI gets brought in to help code, that could easily take the place of Snippets because now, in a way, you effectively have auto-created custom snippets.
All this said, it's Mar 2023 and my custom snippets still don't work on .cshtml pages. Stinks.
The limitations are listed by @ryzngard in #9327:
No Function, Declarations, Id, Import(s), Keyword(s), Literal, Namespace, Object, Reference(s), or Command support.
The listed limitations only apply to custom snippets, correct? Built-in snippets seem to work correctly in the Razor editor, e.g. prop is correctly tabbing through the individual Declarations after inserting.
For custom snippets, if they have a Declaration, they don't insert at all.
@DustinCampbell
C# snippets do not expand in *.razor files Visual Studio 17.2.0
To reproduce: Open *.razor file in Visual Studio, select custom snippet, hit tab twice
Expected behavior: Official blog claims "The new Razor editor now supports snippet functionality in C# code!"
Actual behavior: