Skip to content

Tip 2.38: You can use Ctrl+K, Ctrl+X to insert a code snippet

February 5, 2014

“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’

Sara Ford’s Blog

The keyboard shortcut to insert a code snippet is Ctrl+K, Ctrl+X. It is bound to the command Edit.InsertSnippet, in case your mileage varies, depending on your configuration settings.

She’s going to use C# for this tip, but this tip applies to all languages that support code snippets. When she invokes the Edit.InsertSnippet command, the code snippet insertion UI pops up. The real tip here is that the snippet picker allows for type-ahead selection. Note how she started typing “#re” on the line. (Oh, the fun she had testing this . . . but she digresses.)

Additional keystrokes:

  • You can hit Tab to autocomplete the word. If the word happens to be the code snippet (and not a folder), pressing Tab will insert it.
  • You can also hit Shift+Tab to navigate back to the previous word (her contribution to the insertion UI).

Happy Programming! =)

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: