• 4 hours
  • Easy

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 3/28/24

Use the shortcuts

As you already know, keyboard shortcuts are standard for all computer software. You are familiar with some common shortcuts on Windows like Ctrl-X for cut, Ctrl-C for copy, and Ctrl-V for paste.

Visual Studio has it's own library of shortcuts that can save you time by making you less dependent on your mouse. You can reference all of these shortcuts under each main menu item.

Available shortcuts

In the video below, we'll go through this list of helpful shortcuts that are found under the Edit menu:

  • Collapse/expand selection of code: When you want to hide code that is blocking or distracting your view. Ctrl-M-H and Ctrl-M-U.

  • Comment/uncomment code: Instead of adding "//" to every line you can comment/uncomment blocks of code. Ctrl-K-C and Ctrl-K-U.

  • Tab key for "snippets": This is a very useful shortcut that you should use a lot. In C#, instead of making sure you have brackets for if-conditions, simply type if and press the Tab key twice. You can do these for other code blocks like try-catch, for, class, for each, etc.

  • Surround code with snippet: Like the Tab key above for creating a snippet, you can surround a section of code with a snippet. Select the code and press Ctrl-K-S to display a context menu where you can select a snippet.

  • Find matching braces (C#): For C# development it can be a little annoying trying to find the closing brace "}" to the open one. To find the matching brace of a function or class use Ctrl-]. If you want to select the code between the braces use Ctrl-Shift-].

  • Duplicate the current line: Select your code and Ctrl-C-V.

  • Create/remove bookmarks: Another very useful shortcut you should use so you can quickly get to sections of code you're working on. You can set bookmarks in your code to quickly find and navigate to. With your cursor on a line of code select Ctrl-K-K to set/remove a bookmark. To navigate to the next bookmark select Ctrl-K-N. You can view all your bookmarks by selecting Ctrl-K-W for the bookmark window.

  • Format selection: Sometimes your code layout can get a little sloppy. You can quickly redo spacing and indents by selecting a section of code and use Ctrl-K-F.

Let's recap!

Use shortcuts as early and often as possible to save time when entering code and make you less dependent on your mouse.

Example of certificate of achievement
Example of certificate of achievement