Visual Studio Code Snippets
Today I learned that Visual Studio has a nice little feature called Code Snippets which will insert blocks of code like if statements, class constructors, try-catch blocks, foreach loops, etc.
There are many different ways that you can access code snippets so that you can
use them such as right-clicking where you want to insert code and selecting
‘Insert Snippet…’ from the dropdown. You can also you a keyboard shortcut
Ctrl+K
, Ctrl+X
to access the same menu. My favoriate way though is to start
typing the name of the actual snippet and then press tab
tab
and it will
auto insert the snippet.
Here is a quick example on how to insert a code snippet. Make sure your cursor
is where you want the code to be inserted inside of the Visual Studio editor and
type cw
then press the tab
key twice and it will insert:
Console.Writeline();
and place the cursor write inside of the ()
so that you can continue typing
what you want to print to the console.
I think these Code Snippets are really handy and can increase your development speed and happiness.