Visual

  1. Visual Studio Shortcut Keys
  2. Visual Code Keyboard Shortcut
  3. Microsoft Visual Studio Code Mac Shortcuts Pdf
  4. Format Shortcut Visual Studio Mac
  5. Microsoft Visual Studio Code Mac Shortcuts 2016
-->

You can identify keyboard shortcuts for Visual Studio commands, customize those shortcuts, and export them for others to use. Many shortcuts always invoke the same commands, but the behavior of a shortcut can vary based on the following conditions:

  • Which default environment settings you choose the first time that you open Visual Studio—for example, General Development or Visual C#. (For information about changing or resetting your settings, see Environment settings.)

  • Whether you've customized the shortcut's behavior.

  • Which context you're in when you choose the shortcut. For example, the F2 shortcut invokes the Edit.EditCell command if you're using the Settings Designer and it invokes the File.Rename command if you're using Team Explorer.

Keyboard Shortcut: ⌘K ⌘S (Windows, Linux Ctrl+K Ctrl+S) You can search for shortcuts and add your own keybindings to the keybindings.json file. See more in Key Bindings for Visual Studio Code. Tune your settings. May 15, 2019  Open Visual Studio Code and Navigate to File-Preferences-Keymap Extensions install your choice of keymappings. You can press Ctrl+Shift+P or F1 (windows and Linux users) and ⇧⌘P or F1 (Mac users) to open the command Palette and search for required keyboard shortcuts. Apr 13, 2010 Trying to do this in Visual Studio 2013, but it always just says 'The key combination (Ctrl+K, Ctrl+U) is bound to command (Uncomment Selection) which is not currently available.' The #$%^ its not! I'm editing a local C# file in my project like normal, with a simple block of single-line-commented-out code selected!

Regardless of settings, customization, and context, you can always find and change a keyboard shortcut in the Options dialog box. You can also look up the default keyboard shortcuts for several dozen commands in Popular keyboard shortcuts. For a complete list of all default shortcuts (based on the General Development settings), see All keyboard shortcuts.

If a shortcut is assigned to a command in the Global context and no other contexts, that shortcut will always invoke that command. But a shortcut can be assigned to one command in the Global context and a different command in a specific context. If you use such a shortcut when you're in the specific context, the shortcut invokes the command for the specific context, not the Global context.

Note

Your settings and edition of Visual Studio might change the names and locations of menu commands and the options that appear in dialog boxes. This page is based on the General Development settings profile.

Identify a keyboard shortcut

  1. On the menu bar, choose Tools > Options.

  2. Expand Environment, and then choose Keyboard.

  3. In the Show commands containing box, enter all or part of the name of the command without spaces.

    For example, you can find commands for solutionexplorer.

  4. In the list, choose the correct command.

    For example, you can choose View.SolutionExplorer.

  5. If the command has a keyboard shortcut, it appears in the Shortcut(s) for selected command list.

Customize a keyboard shortcut

  1. On the menu bar, choose Tools > Options.

  2. Expand Environment, and then choose Keyboard.

  3. Optional: Filter the list of commands by entering all or part of the name of the command, without spaces, in the Show commands containing box.

  4. In the list, choose the command to which you want to assign a keyboard shortcut.

    In the Use new shortcut in list, choose the feature area in which you want to use the shortcut.

    For example, you can choose Global if you want the shortcut to work in all contexts. You can use any shortcut that isn't mapped (as Global) in another editor. Otherwise, the editor overrides the shortcut.

    Note

    You can't assign the following keys as part of a keyboard shortcut in Global:

    • Enter, Tab, Caps Lock
    • Print Scrn/Sys Rq, Scroll Lock, Pause/Break
    • Insert, Home, End, Page Up, Page Down
    • The Windows logo key, the Application key, any of the Arrow keys
    • Num Lock, Delete, or Clear on the numeric keypad
    • The Ctrl+Alt+Delete key combination
  5. In the Press shortcut key(s) box, enter the shortcut that you want to use.

    Note

    You can create a shortcut that combines a letter with the Alt key, the Ctrl key, or both. You can also create a shortcut that combines the Shift key and a letter with the Alt key, the Ctrl key, or both.

    If a shortcut is already assigned to another command, it appears in the Shortcut currently used by box. In that case, choose the Backspace key to delete that shortcut before you try a different one.

  6. Choose the Assign button.

    Note

    If you specify a different shortcut for a command, click Assign, and then click Cancel to close the dialog box, the shortcut you assigned is not reverted.

Share custom keyboard shortcuts

Visual Studio Shortcut Keys

You can share your custom keyboard shortcuts by exporting them to a file and then giving the file to others so that they can import the data.

To export only keyboard shortcuts

  1. On the menu bar, choose Tools > Import and Export Settings.

  2. Choose Export selected environment settings, and then choose Next.

  3. Under What settings do you want to export?, clear the All Settings check box, expand Options, and then expand Environment.

  4. Select the Keyboard check box, and then choose Next.

  5. In the What do you want to name your settings file and Store my settings file in this directory boxes, either leave the default values or specify different values, and then choose Finish.

By default, your shortcuts are saved in a file in the %USERPROFILE%DocumentsVisual Studio 2017Settings folder. The name of the file reflects the date when you exported the settings, and the extension is .vssettings.

By default, your shortcuts are saved in a file in the %USERPROFILE%DocumentsVisual Studio 2019Settings folder. The name of the file reflects the date when you exported the settings, and the extension is .vssettings.

To import only keyboard shortcuts

  1. On the menu bar, choose Tools > Import and Export Settings.

  2. Choose the Import selected environment settings option button, and then choose Next.

  3. Choose the No, just import new settings, overwriting my current settings option button, and then choose Next.

  4. Under My Settings, choose the file that contains the shortcuts that you want to import, or choose the Browse button to locate the correct file.

  5. Choose Next.

  6. Under Which settings do you want to import?, clear the All Settings check box, expand Options, and then expand Environment.

  7. Select the Keyboard check box, and then choose Finish.

See also

-->

Code snippets, often referred to as code templates, are useful for efficient programming as they allow the insertion and editing of pre-written blocks of code. Using code snippets can be convenient for quickly adding common patterns, or even for learning new patterns when as the developer you are unsure of syntax. There are templates provided for C#, F#, HTML, XML, Python, and Razor.

This section explains how to create, insert, and use snippets in code.

Inserting a snippet

There are some different ways to add code snippets, some of which are described below:

  • Tab Expansion – Start typing the template name, select it from the list and press Tab, Tab to add it:

  • Toolbox – Use the toolbox pad to display a list of all code snippets. Drag any template from the toolbox into the correct position in the source code:

  • Insert Templates command – There is currently no default key binding set for inserting a template. To create one, browse to Visual Studio > Preferences > Key Bindings and search for template. This allows adding the desired key binding into the Edit Binding field, then click Apply:

Creating a new template

While there are many existing templates in a variety of languages that you can use and edit, new templates can also be added by navigating to Visual Studio > Preferences > Text Editor > Code Snippets:

Press the Add or Edit buttons to create or edit snippets.

Visual Code Keyboard Shortcut

Keywords in code snippets

After a code snippet is inserted into the editor, any keywords defined are highlighted and can be edited by tabbing between them. Keywords behave like a 'variable' in the code snippet and are defined by placing a dollar-sign $ before and after the name of the keyword.

The Edit template window is shown below, editing the built-in prop snippet. The snippet contains two keywords – $type$ and $name$ – which can have further properties set (such as a default value and tooltip) on the right side of the window:

The following fields are used to define a snippet:

  • Shortcut – The text the user types to insert the snippet.
  • Group – Snippets are grouped together in the snippet content menu, using this value.
  • Description – Explanation of the snippet's purpose.
  • Mime – Controls what file types the snippet is available in.
  • Is expandable template – Ensure this is checked so that the snippet can be inserted at the cursor by typing the shortcut.
  • Is surround with template – Check this option to list this shortcut in the Surround with... content menu in the editor.
  • Template text – The actual snippet that will be inserted into the editor. Keyword placeholders can be defined by surrounding a token with dollar signs eg. $type$.
  • Keyword property panel – On the right-side of the window, use the drop-down list at the top to choose a keyword (eg type) and edit properties like default value and tooltip.

Using keywords in the editor

To use a snippet with keywords, such as the one defined above, type the shortcut and press Tab twice, and the snippet contents will be inserted at the cursor:

Press the Tab key to move between object and MyProperty to customize the snippet for your class.

A keyword can be repeated in a snippet, such as this for example, notice the $i$ keyword appears 3 times:

When used in the editor, the Tab key will switch between the first i and max. If you overtype the i with a different variable name, all three instances will be updated:

Microsoft Visual Studio Code Mac Shortcuts Pdf

Reserved keywords

Format Shortcut Visual Studio Mac

There are two reserved keywords that you can use in a snippet:

  • $selected$ – If the snippet has Is surround with template checked, this keyword will be replaced by the text that was highlighted in the editor when the snippet was chosen.
  • $end$ – When the user has finished editing the keywords in a snippet, the cursor will be placed at the location of the $end$ keyword.

The for snippet in the previous section is an example of both these reserved keywords.

Microsoft Visual Studio Code Mac Shortcuts 2016

See also