Skip to content

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

April 16, 2011

“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.
Sara’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.)

Code Snippet Insert

Additional keystrokes:

  • You can hit tab to autocomplete the word. If the word happens to be a 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! =)

Leave a Comment

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: