Snippet basics
At a basic level, snippets can be thought of as small blocks of reusable code. Typically, blocks of snippet code are inserted simply by typing an associated shortcut name such as prop
, foreach
, or ctor
and then pressing Tab twice. Snippets are also accessible via a context menu command, but that approach is much slower and more cumbersome. To give this approach a try, simply right-click while editing a file:
Similarly, it is possible to use the Ctrl + K + X or Ctrl + K + S shortcuts to access available snippets. When you trigger this feature, an Insert Snippet or Surround With selection menu appears. Following this approach is also a good way to explore the list of snippets available for use:
Both Visual Studio Code and Visual Studio for Mac also have snippet pickers as well as tabcompletion capability. Simply type...