26/11/2015
Visual Studio is a powerhouse integrated development environment (IDE) that offers an unparalleled array of features to streamline coding, debugging, and project management. For developers looking to maximise their efficiency, understanding how to swiftly access commands and leverage the editor's advanced capabilities is paramount. This guide will delve into the world of Visual Studio keyboard shortcuts and explore the rich functionalities of its code editor, transforming how you interact with your projects and code.

Mastering Visual Studio with Keyboard Shortcuts
Keyboard shortcuts are the cornerstone of a productive development workflow. In Visual Studio, they provide a rapid pathway to various commands and windows, allowing you to keep your hands on the keyboard and maintain focus. While Visual Studio offers a default set of shortcuts, typically based on the 'General' profile chosen during installation, you have the flexibility to discover and even customise them to fit your unique preferences and work style.
Finding and Customising Shortcuts
To identify the shortcut for any command or to assign a new one, navigate to the Tools menu, select Options, expand the Environment node, and then choose Keyboard. This dialogue box provides a comprehensive list of all commands and their assigned shortcuts. You can search for commands by name or by their current shortcut, making it easy to discover new efficiencies or reconfigure existing ones.
Printable Shortcut Cheat Sheet
For a quick reference, a printable shortcut cheat sheet for Visual Studio is often available from Microsoft's official documentation. This can be an invaluable resource to keep handy as you familiarise yourself with the most frequently used shortcuts.
Key Global Shortcuts for Enhanced Productivity
Global shortcuts are those that are applicable across almost any tool window within Visual Studio, regardless of the active context. Mastering these can significantly reduce reliance on the mouse, making your development process smoother and faster. Below is a selection of some of the most popular and universally useful global shortcuts.
Build Commands
Efficiently manage your project builds with these essential shortcuts.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Build Solution | Ctrl+Shift+B | Build.BuildSolution |
| Cancel | Ctrl+Break | Build.Cancel |
| Compile | Ctrl+F7 | Build.Compile |
| Run Code Analysis on Solution | Alt+F11 | Build.RunCodeAnalysisonSolution |
Debug Commands
Navigate through your code, identify issues, and control execution flow with these debugging shortcuts.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Break All | Ctrl+Alt+Break | Debug.BreakAll |
| Delete All Breakpoints | Ctrl+Shift+F9 | Debug.DeleteAllBreakpoints |
| Exceptions | Ctrl+Alt+E | Debug.Exceptions |
| Quick Watch | Shift+F9 or Ctrl+Alt+Q | Debug.QuickWatch |
| Restart | Ctrl+Shift+F5 | Debug.Restart |
| Start | F5 | Debug.Start |
| Start Without Debugging | Ctrl+F5 | Debug.StartWithoutDebugging |
| Step Into | F11 | Debug.StepInto |
| Step Out | Shift+F11 | Debug.StepOut |
| Step Over | F10 | Debug.StepOver |
| Stop Debugging | Shift+F5 | Debug.StopDebugging |
| Toggle Breakpoint | F9 | Debug.ToggleBreakpoint |
Edit Commands
These shortcuts are indispensable for everyday code manipulation and text editing.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Comment Selection | Ctrl+K, Ctrl+C | Edit.CommentSelection |
| Copy | Ctrl+C or Ctrl+Insert | Edit.Copy |
| Cut | Ctrl+X or Shift+Delete | Edit.Cut |
| Delete | Delete | Edit.Delete |
| Find | Ctrl+F | Edit.Find |
| Find All References | Shift+F12 | Edit.FindAllReferences |
| Find in Files | Ctrl+Shift+F | Edit.FindinFiles |
| Format Document | Ctrl+K, Ctrl+D | Edit.FormatDocument |
| Go To Definition | F12 | Edit.GoToDefinition |
| Insert Snippet | Ctrl+K, Ctrl+X | Edit.InsertSnippet |
| Paste | Ctrl+V or Shift+Insert | Edit.Paste |
| Redo | Ctrl+Y or Ctrl+Shift+Z | Edit.Redo |
| Replace | Ctrl+H | Edit.Replace |
| Select All | Ctrl+A | Edit.SelectAll |
| Undo | Ctrl+Z or Alt+Backspace | Edit.Undo |
File Commands
Quickly manage your project files and solutions.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| New File | Ctrl+N | File.NewFile |
| New Project | Ctrl+Shift+N | File.NewProject |
| Open File | Ctrl+O | File.OpenFile |
| Save All | Ctrl+Shift+S | File.SaveAll |
| Save Selected Items | Ctrl+S | File.SaveSelectedItems |
Project Commands
Add new items and manage your project structure with these shortcuts.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Add Existing Item | Shift+Alt+A | Project.AddExistingItem |
| Add New Item | Ctrl+Shift+A | Project.AddNewItem |
Refactoring Commands
Streamline your code with powerful refactoring operations.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Extract Method | Ctrl+R, Ctrl+M | Refactor.ExtractMethod |
| Rename | Ctrl+R, Ctrl+R | Refactor.Rename |
Tools Commands
Access various utility tools within the IDE.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Attach to Process | Ctrl+Alt+P | Tools.AttachtoProcess |
View Commands
Quickly open and navigate between different Visual Studio windows.

| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Error List | Ctrl+\, Ctrl+E | View.ErrorList |
| Output | Ctrl+Alt+O | View.Output |
| Properties Window | F4 | View.PropertiesWindow |
| Solution Explorer | Ctrl+Alt+L | View.SolutionExplorer |
| Toolbox | Ctrl+Alt+X | View.Toolbox |
Window Commands
Manage your open documents and tool windows efficiently.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Activate Document Window | Esc | Window.ActivateDocumentWindow |
| Close Document Window | Ctrl+F4 | Window.CloseDocumentWindow |
| Next Document Window | Ctrl+F6 | Window.NextDocumentWindow |
| Next Document Window Nav | Ctrl+Tab | Window.NextDocumentWindowNav |
Context-Specific Shortcuts: Tailoring Your Workflow
Beyond global shortcuts, Visual Studio offers context-specific shortcuts that become active when you are working within a particular editor, designer, or tool window. These allow for highly specialised and efficient interactions within that specific environment. Below are examples from various common contexts.
Text Editor Shortcuts
The text editor is where most of your coding happens, and these shortcuts are crucial for efficient typing and navigation.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Break Line | Enter or Shift+Enter | Edit.BreakLine |
| Collapse All Outlining | Ctrl+M, Ctrl+A | Edit.CollapseAllOutlining |
| Contract Selection | Shift+Alt+- | Edit.ContractSelection |
| Document End | Ctrl+End | Edit.DocumentEnd |
| Expand All Outlining | Ctrl+M, Ctrl+X | Edit.ExpandAllOutlining |
| Go To Brace | Ctrl+] | Edit.GotoBrace |
| Insert Tab | Tab | Edit.InsertTab |
| Line Cut | Ctrl+L | Edit.LineCut |
| Move Selected Lines Down | Alt+Down Arrow | Edit.MoveSelectedLinesDown |
| Next Highlighted Reference | Ctrl+Shift+Down Arrow | Edit.NextHighlightedReference |
| Peek Definition | Alt+F12 | Edit.PeekDefinition |
| Toggle Bookmark | Ctrl+K, Ctrl+K | Edit.ToggleBookmark |
| Word Next | Ctrl+Right Arrow | Edit.WordNext |
HTML Editor (Design View) Shortcuts
When working with visual design for web pages, these shortcuts can be very helpful.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Move Control Down | Ctrl+Down Arrow | Edit.MoveControlDown |
| Bold | Ctrl+B | Format.Bold |
| Insert Bookmark | Ctrl+Shift+L | Format.InsertBookmark |
| Show Smart Tag | Shift+Alt+F10 | View.ShowSmartTag |
SQL Editor (Text & Query) Shortcuts
For database developers, these shortcuts enhance interaction with SQL scripts and queries.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Commit All Edits | Shift+Alt+U | CommitAllEdits |
| Execute With Debugger | Alt+F5 | SQL.ExecuteWithDebugger |
| Fully Qualify Names | Ctrl+R, Q or Ctrl+R, Ctrl+Q | SQL.FullyqualifyNames |
| TSql Editor Execute Query | Ctrl+Shift+E | SQL.TSqlEditorExecuteQuery |
| TSql Editor Toggle Results Pane | Ctrl+D, R | SQL.TSqlEditorToggleResultsPane |
Windows Forms Designer Shortcuts
For desktop application development, these shortcuts assist in designing user interfaces.
| Command | Keyboard Shortcut | Command ID |
|---|---|---|
| Move Control Down | Ctrl+Down Arrow | Edit.MoveControlDown |
| Size Control Down | Ctrl+Shift+Down Arrow | Edit.SizeControlDown |
| Tab Left | Shift+Tab | Edit.TabLeft |
Unleashing the Power of the Visual Studio Code Editor
Beyond shortcuts, the Visual Studio code editor itself is packed with features designed to make writing, managing, and understanding code an intuitive experience. From visual aids to intelligent code generation, these functionalities are key to efficient development.
Core Editor Features
- Syntax Highlighting: Different elements of your code (keywords, types, strings, comments) are assigned distinct colours. This visual differentiation greatly improves readability and helps in quickly parsing code structure. You can customise these colours via Tools > Options > Environment > Fonts and Colours.
- Error & Warning Squiggles: As you type, Visual Studio provides instant feedback through coloured squiggly underlines: red for syntax errors, blue for compiler errors, green for warnings, and purple for other issues. These are often accompanied by 'light bulbs' suggesting quick fixes, allowing for immediate problem resolution.
- Brace Matching & Automatic Surround: When your insertion point is on an opening brace, its corresponding closing brace is highlighted, helping you identify misplaced or missing delimiters. Visual Studio 2022 v17.9+ also automatically surrounds selected text with matching delimiters (e.g., quotes, parentheses) when you type the opening delimiter. This can be toggled in Tools > Options > Text Editor > Display.
- Structure Visualiser: Dotted lines connect matching braces and other structural elements, making it easier to see the scope of code blocks. This visual aid is invaluable for navigating large codebases.
- Line Numbers & Change Tracking: Line numbers can be displayed in the left margin for easy reference (enabled in Tools > Options > Text Editor > All Languages). The left margin also tracks changes: yellow for unsaved changes since opening, green for saved changes (before closing), and orange for undone changes after saving.
- Code & Text Selection (Box Mode): Beyond standard streaming selection, Visual Studio supports 'box mode' selection (hold Alt while dragging or use Alt+Shift+Arrow keys). This allows you to select a rectangular block of text, enabling you to type or paste content at the same point on multiple lines simultaneously.
- Zoom & Virtual Space: Zoom in or out of any code window by holding Ctrl and using the mouse scroll wheel (or Ctrl+Shift+. to zoom in, Ctrl+Shift+, to zoom out). The zoom percentage can also be set from the status bar. Virtual space allows the cursor to move beyond the end of a line, which can be useful for certain editing tasks, though it cannot be used with Word Wrap simultaneously.
- Printing Options: The Print dialogue offers options to include line numbers, hide collapsed code regions, and add file paths to headers, providing comprehensive control over your printed code.
- Global Undo & Redo: Found under the Edit menu, these commands apply to actions that affect multiple files, such as renaming a class across a solution or performing a multi-file find-and-replace. This functionality persists even after closing the solution.
Advanced Editing Capabilities
The Edit > Advanced menu offers a suite of powerful functions to enhance your coding experience.
- Document & Selection Formatting: Automatically indent lines and format braces for the entire document (Ctrl+K, Ctrl+D) or a selected portion (Ctrl+K, Ctrl+F), ensuring consistent code style.
- Tabify/Detabify: Convert leading spaces to tabs or tabs to spaces, maintaining coding standards. Commands like
Edit.ConvertSpacesToTabsandEdit.ConvertTabsToSpacescan be accessed via the Command Window. - Case Conversion (Uppercase/Lowercase): Quickly change the case of selected text or the character at the insertion point (Ctrl+Shift+U for uppercase, Ctrl+U for lowercase).
- Moving Lines: Easily move selected lines of code up or down (Alt+Up/Down Arrow), useful for reorganising code blocks.
- Whitespace Management: The 'Show Whitespace' option (Ctrl+R, Ctrl+W) makes spaces visible as dots and tabs as arrows, aiding in identifying and correcting formatting issues. 'Delete Horizontal Whitespace' (Ctrl+K, Ctrl+\) removes trailing spaces.
- Commenting Code: Quickly comment out (Ctrl+K, Ctrl+C) or uncomment (Ctrl+K, Ctrl+U) selected lines or the current line.
- Indentation Control: Increase or decrease the indent of selected lines, providing precise control over code block alignment.
- Tag Selection: In markup files (XML, HTML), select the entire tag or just its content, simplifying editing of structured documents.
Navigating large codebases can be daunting, but Visual Studio provides intelligent tools to help you find your way around.
- Navigation Points: Features like 'Go To' (Ctrl+G to go to a specific line), 'Go To Definition' (F12 or Ctrl+Click on a symbol) to jump to where a type or member is defined, and 'Go To Declaration' (Ctrl+F12) are indispensable for exploring code.
- Bookmarks: Set bookmarks (Ctrl+K, Ctrl+K) on specific lines of code to quickly return to them later. This is great for marking areas you need to revisit.
- Finding References: The 'Find All References' command (Shift+F12) shows you every place a particular code element is used within your solution. Additionally, when you select a type or member, all its references in the active file are automatically highlighted.
Smart Code Generation, Correction, and Refactoring
Visual Studio actively assists you in writing better code faster.
- Code Snippets: Insert pre-defined blocks of code (e.g., a
switchstatement or anif-elseblock) with just a few keystrokes (Ctrl+K, Ctrl+X). - Quick Actions: The 'light bulb' (Ctrl+.) suggests fixes for errors and warnings, and also offers refactorings and code generation options. This could be generating a new method, introducing a local variable, or simplifying expressions.
- Refactoring Tools: Beyond simple renaming (Ctrl+R, Ctrl+R), Visual Studio offers powerful refactorings like 'Extract Method' (Ctrl+R, Ctrl+M), 'Encapsulate Field' (Ctrl+R, Ctrl+E), and 'Reorder Parameters' (Ctrl+R, Ctrl+O), which automatically update all references throughout your codebase.
- Smart Copy & Paste: Visual Studio automatically corrects indentation when you copy code from the IDE and paste it into another application. Furthermore, you can copy JSON or XML text to the clipboard and paste it directly as strongly-typed .NET classes in C# or Visual Basic files using Edit > Paste Special > Paste JSON as Classes (or XML).
Customising Your Visual Studio Environment
Visual Studio allows extensive customisation, from keyboard shortcuts to general settings, which can be shared or reverted as needed.
- Importing & Exporting Settings: Use the Tools > Import and Export Settings Wizard to save your preferred settings (including keyboard shortcuts, window layouts, and theme preferences) to a file. This file can then be imported onto another machine, shared with colleagues, or used to revert to a previous configuration.
- Keyboard Shortcut Customisation: As mentioned earlier, the Tools > Options > Environment > Keyboard dialogue is your hub for personalising shortcuts. Take the time to tailor these to your muscle memory for maximum efficiency.
Frequently Asked Questions (FAQs)
- How do I find a specific command's keyboard shortcut?
- Go to Tools > Options > Environment > Keyboard. In the 'Show commands containing' field, type part of the command's name (e.g., 'build solution'). The assigned shortcut will appear in the 'Shortcut(s) for selected command' box.
- Can I change Visual Studio's default shortcuts?
- Yes, absolutely. In the Keyboard options dialogue, select the command you wish to change, then enter your desired new shortcut in the 'Press shortcut key(s)' box. Choose the scope (e.g., 'Global' or 'Text Editor') from the 'Use new shortcut in' dropdown, and then click 'Assign'.
- What are the main benefits of using keyboard shortcuts?
- Keyboard shortcuts significantly boost productivity by reducing mouse reliance, speeding up navigation, and enabling quicker execution of commands. They help maintain flow state, reducing context switching and cognitive load, especially during repetitive tasks.
- What are the coloured squiggly lines in the editor, and what do they mean?
- These are 'squiggles' that provide real-time feedback on your code. Red indicates a syntax error, blue a compiler error, green a warning, and purple other types of errors or suggestions. They help you catch and fix issues as you code, rather than waiting for compilation.
- How can I quickly reformat my entire code document?
- To automatically format your entire document according to your configured code style settings, use the shortcut Ctrl+K, Ctrl+D. For just a selected portion of code, use Ctrl+K, Ctrl+F.
Conclusion
Mastering Visual Studio's extensive array of keyboard shortcuts and leveraging its rich editor features is a journey that pays dividends in productivity and coding enjoyment. By integrating these tools into your daily workflow, you'll find yourself navigating, writing, and debugging code with unprecedented speed and precision. Take the time to explore, customise, and practise these functionalities, and watch your development efficiency soar.
If you want to read more articles similar to Mastering Visual Studio: Shortcuts & Editor Tips, you can visit the Automotive category.
