As a programmer I use a lot of shortcuts to speed up my work. Using shortcuts instead of the mouse and code against methods or classes before they exist and generate them directly as empty stubs will speed up the work a lot. It will take some time and practice to remember to use shortcuts or code first and generate second, but after a while it will become second nature and save a lot of time focusing on what matters.

Since a couple of my colleagues been asking me to hold a small talk about this at work, I thought I should make a small post about it.

Below is what I use in my daily work

Visual Studio

Editor

  • ALT + arrow up – Move row/s up
  • ALT + arrow down – Move row/s down
  • CTRL + SHIFT + L – Delete row
  • CTRL + L – Cut row
  • CTRL + K, D – Format document
  • CTRL + K, S – Surround with… (mark a section of code to surround with region, try catch or whatever you want)
  • CTRL + R, R – Refactor rename
  • CTRL + R, W – View white space
  • CTRL + E, W – Word wrap
  • CTRL + ALT + L – Solution Explorer
  • CTRL + K, C – Comment section
  • CTRL + K, U – Uncomment section
  • ALT + 12 – Peak view
  • CTRL + F – Find
  • CTRL + SHIFT + F – Find in files
  • ALT + SHIFT + arrows – Mark code and type on multiple rows
  • CTRL + F4 – Close file

Bookmarking

Bookmarks make it quick and easy to navigate in the code you’re working with. Simply put them out where you want to go to quickly

  • CTRL + K, K – Toggle bookmark
  • CTRL + K, N – Go to next bookmark
  • CTRL + K, P – Go to previous bookmark
  • CTRL + K, L – Clear bookmarks

Debug

  • F5 – Debug
  • SHIFT + F5 – Stop debugging
  • CTRL + F5 – Start without debugging
  • CTRL + ALT + P – Attach to process
  • F9 – Toggle breakpoint
  • CTRL + SHIFT + F9 – Delete all breakpoints
  • F10 – Step over
  • F11 – Step into
  • SHIFT + F11 – Step out

IntelliSense

  • CTRL + J – List members
  • CTRL + Space – Complete word
  • CTRL + ALT + Space – Parameter info
  • CTRL + K + I – Quick info
  • CTRL + SHIFT + SPACE – Show method parameter tooltip

Outlining

This is a great way of getting a better overview of the code, only display how much you want.

  • CTRL + M, M – Toggle outlining expansion
  • CTRL + M, L – Toggle all outlining
  • CTRL + M, P – Stop Outlining
  • CTRL + M, U – Stop hiding outlining
  • CTRL + M, O – Collapse to definition

Snippets

There are a lot of useful snippets out there, these are the ones I mainly use.

  • CTRL + K + X – Insert snippet
  • Ctor – Create constructor
  • Prop – Create auto property
  • Pci – public const int
  • Pcs – public const string
  • Class – Create class

Visual Studio Team Explorer

These shortcuts make it a lot quicker to use the team explorer, I love the quickness of getting to pending changes to find the current files I’ve been working with. They all start with CTRL + 0 (zero) and the letter is the initial letter of which window you want to go to which make it simple to remember.

  • CTRL + 0, H – Home
  • CTRL + 0, P – Pending changes
  • CTRL + 0, W – Work items
  • CTRL + 0, B – Builds
  • CTRL + 0, C – Connect

Extensions

Two of my favorite extensions for Visual Studio is CodeMaid and ReSharper. Both are excellent at what they do and they help me keep the code tidy and save me a lot of time.

CodeMaid

A very useful extension that don’t take up a lot of system resources. This is a tool which all with a sense of tidiness should use. Find out more about this excellent extension here.

  • CTRL + M, Space – Clean code
  • CTRL + M, Z – Reorganize document
  • CTRL + M, F – Find in solution explorer
  • CTRL + M, J – Join lines
  • CTRL + M, R – Remove all regions
  • CTRL + M, , (comma) – Switch between view and code behind

ReSharper

Most of you have probably used or heard about this powerful extension. I know a lot of developers that only use the “ReSharper tell me to change this to a linq expression” or “use var instead of string”, but when you start using it with shortcuts it take it to the next level. The more used you get to use different parts the more useful it becomes.

Edit

  • CTRL + SHIFT + Space – Import symbol
  • ALT + SHIFT + Space – Smart code completion
  • CTRL + SHIFT + R – Refactor this…
  • CTRL + D – Duplicate
  • CTRL + SHIFT + , (comma) – Go to recent edits
  • ALT + Ins – Generate code…
  • CTRL + ALT + Right arrow – Extend selection, use CTRL + ALT + Left arrow to go back to previos selection

Navigation

  • CTRL + T – Go to everything
  • CTRL + SHIFT + T – Go to file
  • ALT + SHIFT + T – Go to symbol

Rearrange code

This is a lot more powerful than using the move line that is part of the Visual Studio Editor

  • CTRL + ALT + SHIFT + Arrow Up/Down/Left/Right
  • Arrow up/down
    • Move a single row
    • Move a complete block. Example: Move if statement or using if using it on that row
    • Move a whole method above/below the next/previous method
  • Arrow left/right
    • Move parameters. Example: change order or parameter inside a method declaration
    • Move a grouped code in and out of other methods. Example: move a line or block outside an if statement

What else

Beside using the shortcuts that is a direct call to a specific task. I like to use the ALT key to trigger the menus. For example if I want to show the Source Control Explorer that hasn’t got a default shortcut (which you can set) I use ALT + V, E, S which will trigger View, Other Windows and Solution Explorer.

If I have missed anything or you have a favorite shortcut please add a comment. I always love to find things that let me keep more time with the code and less time searching in menus.

2 thoughts on “Visual Studio shortcuts for faster programming

Leave a Reply

Your email address will not be published. Required fields are marked *