How to complete a Visual Studio snippet in VB.NET?
Asked Answered
M

2

7

In C# if you start a snippet you press Tab to cycle through the snippet elements, and press Enter to complete and exit the snippet.

In VB.NET you still use Tab to cycle through the snippet elements, but how do you end the snippet? Enter doesn't work and I can't figure out the correct keyboard shortcut

Masseter answered 28/1, 2011 at 17:23 Comment(1)
I find this really annoying as well.Oder
C
3

VB snippets don't work the same way as C# snippets. VB snippets don't have an 'end' and instead stay active until you start typing outside of the snippet scope. The best method is to press esc (once or twice depending on your current selection) and then use the arrow keys to navigate.

A great demo video is available on MSDN. It focusses mostly on C# but has some explanation of the VB snippets at the end.

For more information check out the keybinding posters

Cenozoic answered 8/3, 2013 at 3:37 Comment(0)
R
1

Enter doesn't work? It's always worked for me when, for example, I add a new line after the end of the snippet. Alternately, you should be able to end a snippet just by navigating somewhere else in the code and typing (or deleting) something.

Ravishment answered 28/1, 2011 at 18:9 Comment(1)
I guess that is the key difference. With the C# snippet, you press enter at any point within the snippet and the snippet is completed and the cursor is placed on the line following the generated code. With VB.NET, you have to move the cursor yourself to the end of the generated code, then press enter.Masseter

© 2022 - 2024 — McMap. All rights reserved.