[.net] Favorite Visual Studio keyboard shortcuts

What is your favorite Visual Studio keyboard shortcut? I'm always up for leaving my hands on the keyboard and away from the mouse!

One per answer please.

This question is related to .net visual-studio keyboard-shortcuts

The answer is


Ctrl + K + C - set current selected code to be comments Ctrl + K + U - set current selected comments to be code


Ctrl + - and the opposite Ctrl + Shift + -.

Move cursor back (or forwards) to the last place it was. No more scrolling back or PgUp/PgDown to find out where you were.

This switches open windows in Visual Studio:

Ctrl + tab and the opposite Ctrl + Shift + tab


Insert snippet:

Ctrl+K, Ctrl+S

I use if often for try..catch and #region


My favorite: F12 (go to definition) and Shift+F12 (find references).

The latter is useful with F8 (go to next result).

Ctrl+- and Ctrl+Shift+- are mapped to my mouse's back and forwards buttons.

Ctrl+. is useful too, especially for adding event handlers and "using" statements.


CTRL + Alt +

This causes the list of open files to pop open in the upper right corner of the editor window. The cool thing is that it is searchable so you can leave go of the keys and start typing the file name to shift the focus to that file. Very handy when you have zillions of files open.


CTRL+F5 (Start Without Debugging)

CTRL+SHIFT+B (Build Solution)


By far the most useful (after Ctrl+Shift+B) are:

  • Ctrl+K, C - to Comment out selection

  • Ctrl+k, U - to Uncomment a selection

My favorite: F12 (go to definition) and Shift+F12 (find references).

The latter is useful with F8 (go to next result).

Ctrl+- and Ctrl+Shift+- are mapped to my mouse's back and forwards buttons.

Ctrl+. is useful too, especially for adding event handlers and "using" statements.


Ctrl + I for incremental search.


Ctrl+Space, Visual Studio gives the possible completions.


Not a keyboard shortcut, but with your mouse, you can use forward and backwards buttons on your mouse to go to previous locations in your code and return to your current location.


If you have your keyboard settings set to the "Visual C# 2005" setting, the window switching and text editing chords are excellent. You hit the first combination of Ctrl + Key, then release and hit the next letter.

  • Ctrl+E, C: Comment Selected Text

  • Ctrl+E, U: Uncomment Selected Text

  • Ctrl+W, E: Show Error List

  • Ctrl+W, J: Show Object Browser

  • Ctrl+W, S: Show Solution Explorer

  • Ctrl+W, X: Show Toolbox

I still use F4 to show the properties pane so I don't know the chord for that one.

If you go to the Tools > Customise menu option and press the Keyboard button, it gives you a list of commands you can search to see if a shortcut is available, or you can select the "Press Shortcut Keys:" textbox and test shortcut keys you want to assign to see if they conflict.

Addendum: I just found another great one that I think I'll be using quite frequently: Ctrl+K, S

pops up an intellisense box asking you what you would like to surround the selected text with. It's exactly what I've needed all those times I've needed to wrap a block in a conditional or a try/catch.


Ctrl+Shift+F

Good old Find In Files.


The TAB key for "snippets".

E.g. type try and then hit the tab key twice.

Results in:

try 
{           

}
catch (Exception)
{

    throw;
}

which you can then expand.

Full list of C# Snippets: http://msdn.microsoft.com/en-us/library/vstudio/z41h7fat.aspx


Commenting

  • Ctrl+K, Ctrl+C - Comment current item

  • Ctrl+K, Ctrl+U - Uncomment current item

The great thing about this is that it applies to the element you're currently in - you don't have to select a whole line of VB code to comment it, for example, you just type Ctrl+K, Ctrl+C to comment the current line. On an aspx page, you can comment out a big chunk of code - for example an entire ListView - by just going to the first line and hitting Ctrl+K, Ctrl+C.


By usage, the pair:

  • Ctrl+Enter: insert blank line above the current line.
  • Ctrl+Shift+Enter: insert blank line below the current line.

Open a file without using the mouse:

CTRL + ALT + A (opens command window) Followed by >open somedoc

I didn't see this one yet. Can't believe how many cool shortcuts have been posted here!


Here is a list that I use frequently:

Ctrl + I: for progressive search. If you don't type anything after I, and keep pressing I (holding the Ctrl key down), it will search the last item you had searched. Ctrl + Shift + I will reverse search. You might also want to use F3 (and Shift + F3) once some search string is entered.

Ctrl + K Ctrl + C: For commenting highlighted region. If nothing is highlighted, current line will be commented. Naturally, you can just hold Ctrl and press K, C in succession.

Ctrl + K Ctrl + U: For uncommenting highlighted region. Works like above.

Ctrl + /: Will take the cursor to the small search box on top. You can type ">of filename" (without the quotes) to open a file. Very useful if your project contains multiple files.

Ctrl + K Ctrl + K: Will bookmark the current line. This is useful if you want to look at some other part of code for a moment and come back to where you were.

Ctrl + K Ctrl + N: Will take you to the next bookmark, if there are more than one.

Ctrl + -: Will take the cursor to its previous location

Ctrl + Shift + -: Will take the cursor to its next location (if it exists)

Ctrl + Shift + B: Build your project

Ctrl + C: Although this does the usual copy, if nothing is highlighted, it copies the current line. Same for Ctrl + X (for cut)

Ctrl + Space: Autocomplete using IntelliSense

Ctrl + ]: Will take you to the matching brace. Works with all kinds of braces: '(', '{', '['. Useful for big blocks.

F12: Will take you to the function definition/variable definition.

Alt + P + P: Will open up project properties. Although not many use this, it useful if you want to quickly change the command line arguments to your program.

F5: To start debugging

Shift + F5: To stop debugging

While debugging, you can use Ctrl + Alt + Q to add a quick watch. Other debugging shortcuts can be found in the debug drop down menu.


I've mapped File.Close to CTRL+SHIFT+W. That and CTRL+TAB mean you can close exactly whichever files you want.


Cutting and pasting lines

Everyone knows Ctrl + X and Ctrl + C for cutting/copying text; but did you know that in VS you don't have to select the text first if you want to cut or copy a single line? If nothing is selected, the whole line will be cut or copied.


It's simple, but

Ctrl + L

deletes the entire line. Great for fast code editing.


Ctrl+- and Ctrl+Shift+-

Alt+D, P Attach the debugger to the application.

(first letter of any application you want to debug, works most of the time)

Ctrl+Shift+F

Ctrl+I (incremental seach)


If you install Visual Assist X, which I highly recommend you do, these are useful:

  • Alt+O: Toggle current document between header/implementation (.h/.cpp)

  • Alt+G: Go to definition/declaration


Outlining

  • ctrl+M, ctrl+M - Collapse/expand current element

  • ctrl+M, ctrl+O - Collapse all (gives you a nice overview of a complex class, for example)

  • ctrl+M, ctrl+O - Toggle all

This works both in VB/C# code (e.g. collapse/expand a function) and in an aspx page (e.g. collapse/expand a GridView definition).

One very nice use of this is to cut or copy a big chunk of markup or code: For example, to move a big, sprawling <table> or <asp:gridview> definition:

  1. Go to the first line

  2. ctrl+M, ctrl+M to collapse it

  3. ctrl+X to cut it (you don't have to select it, as long as your insertion point is still in that line)

  4. Move to where you want it and ctrl+V to paste.

Use Emacs-like keybinding, it's TAB :P


Nothing beats Ctrl+Shift+B - Building the solution!!

As far as navigation control, Ctrl+- and Ctrl++ is nice...

But I prefer Ctrl+K+K ---> creates bookmark...

and Ctrl+K+N ---> to navigate to the next bookmark... awesome stuff...


Hopefully this hasn't already been posted, apologies if so. I've just come across a useful keyboard shortcut in Visual Studio 2008. With the QuickWatch window open, highlight a row with a string value in it and hit Space Bar. The text visualiser window will appear with the value in it.

I have found it quite useful for checking jQuery innerText values as the QuickWatch window by default is too small to show longer strings fully.


Ctrl+C, Ctrl+V to duplicate the current line

Ctrl+L to delete the current line

Ctrl+F3 to search for the current selection

Ctrl+K, Ctrl+K to create a bookmark (which are useful)

Ctrl+K, Ctrl+N to go to the next bookmark

And, here is something even more interesting:
Press Ctrl+/ to put the cursor into a box where you can type commands.

For example, Pressing Ctrl+/ and type ">of ", now start typing the name of a file in your project, and it will autocomplete. This is a very fast way to open files in the current solution.


F7 toggles from design view to code view.


Ctrl + - and the opposite Ctrl + Shift + -.

Move cursor back (or forwards) to the last place it was. No more scrolling back or PgUp/PgDown to find out where you were.

This switches open windows in Visual Studio:

Ctrl + tab and the opposite Ctrl + Shift + tab


Insert snippet:

Ctrl+K, Ctrl+S

I use if often for try..catch and #region


If 'Favorite' is measured by how often I use it, then:

F10 : Debug.StepOver

:)


I just found out that Shift+F11 steps out of the current function.

This is very useful when you want to debug function foo in foo(bar(baz()). Use F11, Shift+F11 to jump in and out of bar and baz.


Alt + B + U - Build the current project.


VS 2008

  1. Ctrl+E,D : Format Code

  2. Ctrl+M,O : Collapse To Definitions

  3. Ctrl+Z : Undo :)

  4. F9: Breakpoint

  5. Ctrl+Shift+F9 : Delete All Breakpoints


Refresh javascript intellisense and code coloring.


ctrl+shift+J

I've found intellisense for Javascript to be flaky - this usually straightens it out.


For me, it's nothing to do about auto completing code, matching parenthesis or showing some fancy tool panel. Instead, it's just about letting me see the code.

With all the panels surrounding you, the area you use to actually write code becomes too small.

In this cases, Shift+Alt+Enter comes in to the rescue and gets the code window in focus in full screen mode. Hit it again, and you have all the panels back.


F7 toggles from design view to code view.


Incremental Search - Ctrl + I

It's basically the find dialog box without the dialog box. Just start typing what you want to search for (look at the bottom status bar location to see what you've typed). Pressing Ctrl + I again or F3 searches for the next instance. Press Escape to quit. Starting a new search by pressing Ctrl + I twice repeats the last search.


CTRL+F5 (Start Without Debugging)

CTRL+SHIFT+B (Build Solution)


I like Ctrl+M, Ctrl+M. To expand/collapse the current code block.


I just found out that Shift+F11 steps out of the current function.

This is very useful when you want to debug function foo in foo(bar(baz()). Use F11, Shift+F11 to jump in and out of bar and baz.


I'm addicted to some very subtle stuff in http://blog.jpboodhoo.com/UsefulVSKeySequencesShortcuts.aspx

e.g. Alt-W U to auto collapse everything when in Full screen mode when it all gets too much


I have two that I use a lot, the first is standard, the second you have to map:

Ctrl+A, Ctrl+E, F (Select All, Format Selection)

Ctrl+E, R (Remove Unused Usings and Sort)

Both help pay down the "cruft debt" early and often


Surround with: Ctrl + K , S.

It is great when you want to wrap some text in a tag.


I'm addicted to some very subtle stuff in http://blog.jpboodhoo.com/UsefulVSKeySequencesShortcuts.aspx

e.g. Alt-W U to auto collapse everything when in Full screen mode when it all gets too much


Ctrl+C, Ctrl+V to duplicate the current line

Ctrl+L to delete the current line

Ctrl+F3 to search for the current selection

Ctrl+K, Ctrl+K to create a bookmark (which are useful)

Ctrl+K, Ctrl+N to go to the next bookmark

And, here is something even more interesting:
Press Ctrl+/ to put the cursor into a box where you can type commands.

For example, Pressing Ctrl+/ and type ">of ", now start typing the name of a file in your project, and it will autocomplete. This is a very fast way to open files in the current solution.


Ctrl+K, Ctrl+D - Format the current document.

Helped me fix indentation and remove unneeded spaces quickly


I like Ctrl+M, Ctrl+M. To expand/collapse the current code block.


Ctrl+Shift+R -> Refactor with Resharper


I hate closing the extra tabs when I use "Start Debugging" on ASP.NET apps. Instead, I usually use "Start without Debugging" (Ctrl+F5).

If I end up needing to debug, I use Ctrl+Alt+P (Attach to Process)

and choose WebDev.WebServer.exe. Then I'm still on my previous page and I only have one tab open.


Snippets

Each snippet has a shortcut that you can access by typing a word then tab. The one I use the most is for a standard property definition; just type property then tab.


I like Ctrl+M, Ctrl+M. To expand/collapse the current code block.


Open and set focus in Solution Explorer: Ctrl+Alt+L


I hate closing the extra tabs when I use "Start Debugging" on ASP.NET apps. Instead, I usually use "Start without Debugging" (Ctrl+F5).

If I end up needing to debug, I use Ctrl+Alt+P (Attach to Process)

and choose WebDev.WebServer.exe. Then I'm still on my previous page and I only have one tab open.


Visual Studio 2005/2008 keybinding posters:

These don't cover customizations, but they're good reference materials and definitely helpful for finding new shortcuts.

Also, a macro that dumps all the current bindings to a HTML file:

http://www.codinghorror.com/blog/archives/000315.html


Ctrl+Shift+space shows the syntax/overloads for the current function you are typing parameters for.


Paste in loop Ctrl + Shift + V

Expand Collapse current block - Ctrl + M + M

Code Snippet - for creating property type prop and press tab.


Ctrl+Shift+B - Build


Simple one. F8 : Go to next build error.

Found that now it will work in any sort of list window (the ones that cluster together at the bottom usually.


By far the most useful (after Ctrl+Shift+B) are:

  • Ctrl+K, C - to Comment out selection

  • Ctrl+k, U - to Uncomment a selection

Expand Smart Tag (Resolve Menu): Ctrl + . (period)

Expands the tag that shows when you do things like rename an identifier.


Open a newline above Ctrl + Enter

Open a newline below Ctrl + Shift + Enter


Alt+F4 ;)

But on a more serious note, Ctrl+Space is probably hit a lot from me, in my limited usage of VS.


For me, it's nothing to do about auto completing code, matching parenthesis or showing some fancy tool panel. Instead, it's just about letting me see the code.

With all the panels surrounding you, the area you use to actually write code becomes too small.

In this cases, Shift+Alt+Enter comes in to the rescue and gets the code window in focus in full screen mode. Hit it again, and you have all the panels back.


I like my code clean and arranged so my favorite keyboard shortcuts are the following:

Ctrl+K,D - Format document

Ctrl+K,F - Format selected code

Ctrl+E,S - Show white spaces

Ctrl+L - Cut line

Alt+Enter - Insert line below


I have two that I use a lot, the first is standard, the second you have to map:

Ctrl+A, Ctrl+E, F (Select All, Format Selection)

Ctrl+E, R (Remove Unused Usings and Sort)

Both help pay down the "cruft debt" early and often


Some handy ones that I use often are:

Ctrl+J -> Forces Intellisence to pop up.

Ctrl+Alt+L -> Show the Solution Explorer.


If you install Visual Assist X, which I highly recommend you do, these are useful:

  • Alt+O: Toggle current document between header/implementation (.h/.cpp)

  • Alt+G: Go to definition/declaration


Ctrl+Shift+S

Save all changed files. saved me quite a few times.


F7 to build and then F8 to go to the errors and warnings one by one.


Open a file without using the mouse:

CTRL + ALT + A (opens command window) Followed by >open somedoc

I didn't see this one yet. Can't believe how many cool shortcuts have been posted here!


Ctrl + Alt + E = Exception/Catch Settings and code snippets


Paste in loop Ctrl + Shift + V

Expand Collapse current block - Ctrl + M + M

Code Snippet - for creating property type prop and press tab.


I hate closing the extra tabs when I use "Start Debugging" on ASP.NET apps. Instead, I usually use "Start without Debugging" (Ctrl+F5).

If I end up needing to debug, I use Ctrl+Alt+P (Attach to Process)

and choose WebDev.WebServer.exe. Then I'm still on my previous page and I only have one tab open.


It's simple, but

Ctrl + L

deletes the entire line. Great for fast code editing.


Ctrl+I for incremental search


Open and set focus in Solution Explorer: Ctrl+Alt+L


Outlining

  • ctrl+M, ctrl+M - Collapse/expand current element

  • ctrl+M, ctrl+O - Collapse all (gives you a nice overview of a complex class, for example)

  • ctrl+M, ctrl+O - Toggle all

This works both in VB/C# code (e.g. collapse/expand a function) and in an aspx page (e.g. collapse/expand a GridView definition).

One very nice use of this is to cut or copy a big chunk of markup or code: For example, to move a big, sprawling <table> or <asp:gridview> definition:

  1. Go to the first line

  2. ctrl+M, ctrl+M to collapse it

  3. ctrl+X to cut it (you don't have to select it, as long as your insertion point is still in that line)

  4. Move to where you want it and ctrl+V to paste.

Ctrl+K, Ctrl+D // Auto-(Re)Format

See Also: Answer


Surround with: Ctrl + K , S.

It is great when you want to wrap some text in a tag.


There are some great tips and trips and shortcuts on Sara Ford's blog.


Ctrl+Shift+space shows the syntax/overloads for the current function you are typing parameters for.


Ctrl+M, O. Can collapse and expand all sections of code in a particular file.


Showing hidden windows

  • ctrl+alt+L + Solution explorer

  • ctrl+alt+S + Server explorer

  • ctrl+alt+O + Output

  • ctrl+alt+X + Toolbox

  • ctrl+shift+W, 1 + Watch

  • ctrl+\, E + Error list

  • ctrl+shift+C + Class view

I like to use all my screen real estate for code and have everything else hidden away. These shortcuts keep these windows handy when I need them, so they can be out of the way the rest of the time.


Ctrl+ E + D : Format Document

Tip for teams: Set up agreed-on formatting options in Visual Studio (they are very flexible), then export the settings to a .settings file for each developer to import.

Now if all developers learn to autoformat everything, it will not only produce perfect formatting consistency throughout the project with no effort at all, but also greatly reduce annoying false differences in the diff tool when merging multiple check-ins to Source Control.

Oh, I enjoy good tools!


Simple one. F8 : Go to next build error.

Found that now it will work in any sort of list window (the ones that cluster together at the bottom usually.


Hmmm, nobody said F1 for help.

Could it be that Google is faster and better for getting at the information that you need.


Ctrl+M, O. Can collapse and expand all sections of code in a particular file.


I mapped all of the expand/collapse commands so that they can be used with the left and only so my right hand stays on my mouse.
Ctrl + E, Ctrl + E toggles expansion,Ctrl + E, Ctrl + D collapses all to definitions, Ctrl + E, Ctrl + A toggles all outlining.


What Ray said. Ctrl + ..

I really didn't like the smart tags (those little blue and red underscores that appear wanting to help you) until I found out that you don't need to waste time trying to hover the mouse over the exact pixel that gets the menu to show.

I think Ctrl + . to open the smart tag menu saves me about five minutes every day and reduces my blood pressure considerably.


Alt+Shift+arrow keys(,,,)

This allow you to select things in a block. Like you could select all of the "int" in the block and then search and replace to double for example.

**int** x = 1;
**int** y = 2;
**int** z = 3;

Ctrl+] for matching braces and parentheses.

Ctrl+Shift+] selects code between matching parentheses.


I'm a big fan of Ctrl + D + Q to open quickwatch while debugging.


CTRL+F5 (Start Without Debugging)

CTRL+SHIFT+B (Build Solution)


Ctrl + BP (Previous bookmark), Ctrl + BN (Next bookmark)


Ctrl+[ (Move to corresponding })

Ctrl+Shift+V (Cycle clipboard)


Hmmm, nobody said F1 for help.

Could it be that Google is faster and better for getting at the information that you need.


Ctrl+Shift+V multiple times cycles through the clipboard ring.


Format document

   Ctrl+K, Ctrl+D
  1. On an aspx page, this takes care of properly indenting all of your markup and ensures that everything is XHTML compliant (adds quotes to attributes, corrects capitalization, closes self-closing tags). I find that this makes it much easier to find mismatched tags and to make sure that my markup makes sense. If you don't like how it's indenting, you can control which tags go on their own line and how much space they get around them under Tools/Options/Text Editor/HTML/Format/Tag Specific Options.

  2. In your C# or VB code, this will correct any capitalization or formatting issues that didn't get caught automatically.

  3. For CSS files, you can choose compact (one definition per line), semi-expanded, or expanded (each rule on its own line); and you can choose how it handles capitalization.


Visual Studio 2005/2008 keybinding posters:

These don't cover customizations, but they're good reference materials and definitely helpful for finding new shortcuts.

Also, a macro that dumps all the current bindings to a HTML file:

http://www.codinghorror.com/blog/archives/000315.html


VS 2008

  1. Ctrl+E,D : Format Code

  2. Ctrl+M,O : Collapse To Definitions

  3. Ctrl+Z : Undo :)

  4. F9: Breakpoint

  5. Ctrl+Shift+F9 : Delete All Breakpoints


Save LOTS of time copy and cutting:

  • Ctrl+C with no selection in the line: copies the whole line

  • Ctrl+X with no selection - cuts the whole line

What Ray said. Ctrl + ..

I really didn't like the smart tags (those little blue and red underscores that appear wanting to help you) until I found out that you don't need to waste time trying to hover the mouse over the exact pixel that gets the menu to show.

I think Ctrl + . to open the smart tag menu saves me about five minutes every day and reduces my blood pressure considerably.


Hmmm, nobody said F1 for help.

Could it be that Google is faster and better for getting at the information that you need.


Ctrl+X

This cuts (to clipboard) the current line of code.


The combination Ctrl+F3 and Ctrl+Shift+F3 for finding selected and previous selected item works very well for me.


Ctrl+Alt+P -> Attach to process


Another useful Find short key sequence is Ctrl (+ Shift) F --> ALT C --> ALT W for switching between exact and fuzzy searches.


I've mapped File.Close to CTRL+SHIFT+W. That and CTRL+TAB mean you can close exactly whichever files you want.


Good old Ctrl+Tab for flipping back and forth between open documents.

Visual Studio actually provides a very nice Ctrl+Tab implementation; I especially appreciate that the Ctrl+Tab document activation order is most-recently-used order, rather than simple "left-to-right" order, so that Ctrl+Tab (press once and release) can be used repeatedly to flip back and forth between the two most-recently-used documents, even when there are more than two documents open.


Alt+F4 ;)

But on a more serious note, Ctrl+Space is probably hit a lot from me, in my limited usage of VS.


Shift+ESC

This hides/closes any of the 'fake window' windows in Visual Studio. This includes things like the Solution Explorer, Object Browser, Output Window, Immediate window, Unit Test Windows etc. etc. and still applies whether they're pinned, floating, dockable or tabbed.

Shortcut into a window (e.g. Ctrl + Alt + L or Ctrl + Alt + I) do what you need to do, and Shift + Esc to get rid of it. If you don't get rid of it, the only way to give it focus again is to use the same keyboard shortcut (or the mouse, which is what we're trying to avoid....)

Once you get the hang of it, it's immensely useful.


Grrr....The amount of times of hit Ctrl + F4 to close the 'window' only to see my current code window close was insane before I found this, now it only happens occasionally..


CTRL+F5 (Start Without Debugging)

CTRL+SHIFT+B (Build Solution)


Well, if you're really

always up for leaving my hands on the keyboard and away from the mouse!

Than you should go here

It's not really my favorite, it's just everything!

A shortcut a day will keep the mouse away.


When the IntelliSense drop down is displayed, holding down Ctrl turns the list semi-transparent so you can see what is hidden behind it :)


Ctrl+A, K, F

Select all, prettyprint.


The combination Ctrl+U and Ctrl+Shift+U for converting a block of characters to all upper/lower case.


Ctrl+] for matching braces and parentheses.

Ctrl+Shift+] selects code between matching parentheses.


Ctrl+Shift+Alt+B Rebuild Solution.

Ctrl+R, Ctrl+T Debug Tests in Current Context


Ctrl+K, Ctrl+C Comment a block

Ctrl+K, Ctrl+U Uncomment the block


Nothing beats Ctrl+Shift+B - Building the solution!!

As far as navigation control, Ctrl+- and Ctrl++ is nice...

But I prefer Ctrl+K+K ---> creates bookmark...

and Ctrl+K+N ---> to navigate to the next bookmark... awesome stuff...


The combination Ctrl+F3 and Ctrl+Shift+F3 for finding selected and previous selected item works very well for me.


Ctrl+] for matching braces and parentheses.

Ctrl+Shift+] selects code between matching parentheses.


Ctrl + Alt + E = Exception/Catch Settings and code snippets


Alt+Shift+ Arrow keys() or mouse moving = Block/Column selection

comes really handy


Ctrl+Shift+8 - Backtracks go to previous "F12/ Go to definition"


Ctrl+K, Ctrl+D - Format the current document.

Helped me fix indentation and remove unneeded spaces quickly


Ctrl + I for incremental search.


Alt+Shift+arrow keys(,,,)

This allow you to select things in a block. Like you could select all of the "int" in the block and then search and replace to double for example.

**int** x = 1;
**int** y = 2;
**int** z = 3;

One that I use often but not many other people do is:

Shift + Alt + F10 then Enter

If you type in a class name like Collection<string> and do not have the proper namespace import then this shortcut combination will automatically insert the import (while the carret is immediately after the '>').

Update:

An equivalent shortcut from the comments on this answer (thanks asterite!):

Ctrl + .

Much more comfortable than my original recommendation.


Ctrl+X

This cuts (to clipboard) the current line of code.


One that other editors should take up: Ctrl+C with nothing selected will copy the current line.

Most other editors will do nothing. After copying a line, pasting will place the line before the current one, even if you're in the middle of the line. Most other editors will start pasting from where you are, which is almost never what you want.

Duplicating a line is just: Hold Ctrl, press c, then v. (Ctrl+C, Ctrl+V)


Good old Ctrl+Tab for flipping back and forth between open documents.

Visual Studio actually provides a very nice Ctrl+Tab implementation; I especially appreciate that the Ctrl+Tab document activation order is most-recently-used order, rather than simple "left-to-right" order, so that Ctrl+Tab (press once and release) can be used repeatedly to flip back and forth between the two most-recently-used documents, even when there are more than two documents open.


The TAB key for "snippets".

E.g. type try and then hit the tab key twice.

Results in:

try 
{           

}
catch (Exception)
{

    throw;
}

which you can then expand.

Full list of C# Snippets: http://msdn.microsoft.com/en-us/library/vstudio/z41h7fat.aspx


Some handy ones that I use often are:

Ctrl+J -> Forces Intellisence to pop up.

Ctrl+Alt+L -> Show the Solution Explorer.


Ctrl + K, D to auto format code.


Not a keyboard shortcut, but with your mouse, you can use forward and backwards buttons on your mouse to go to previous locations in your code and return to your current location.


Control+Apostrophe.

Oh wait, that was after I remapped it away from that god-awkward Alt+Shift+F10 or whatever it was.

When you remap options to help bind this away from it's original hard to hit shortcut, it becomes a lot lot more useful.


Ctrl+A, K, F

Select all, prettyprint.


By far the most useful (after Ctrl+Shift+B) are:

  • Ctrl+K, C - to Comment out selection

  • Ctrl+k, U - to Uncomment a selection

Ctrl+Shift+F

Good old Find In Files.


Turn line wrapping on and off

Ctrl+E, Ctrl+W

Sometimes you want to see the flow of the code with all of your indents in place; sometimes you need to see all 50 attributes in a GridView declaration. This lets you easily switch back and forth.


Ctrl+Shift+R -> Refactor with Resharper


Open and set focus in Solution Explorer: Ctrl+Alt+L


Ctrl+M, O. Can collapse and expand all sections of code in a particular file.


Ctrl + Alt + E = Exception/Catch Settings and code snippets


Expand Smart Tag (Resolve Menu): Ctrl + . (period)

Expands the tag that shows when you do things like rename an identifier.


Commenting

  • Ctrl+K, Ctrl+C - Comment current item

  • Ctrl+K, Ctrl+U - Uncomment current item

The great thing about this is that it applies to the element you're currently in - you don't have to select a whole line of VB code to comment it, for example, you just type Ctrl+K, Ctrl+C to comment the current line. On an aspx page, you can comment out a big chunk of code - for example an entire ListView - by just going to the first line and hitting Ctrl+K, Ctrl+C.


Ctrl+K, Ctrl+C Comment a block

Ctrl+K, Ctrl+U Uncomment the block


Ctrl + , for 'Navigate To' window (link)


There are some great tips and trips and shortcuts on Sara Ford's blog.


Here's a link to a list of Shortcuts I find usefull (VS2003) but some still apply,

My favorite being F12 and Ctrl+- to navigate to the declaration and back


I think Ctrl + K + D is definitely my favourite. I use it more than any other shortcuts. It helps to format the document according to the indentation and code formatting settings specified by us.


Some handy ones that I use often are:

Ctrl+J -> Forces Intellisence to pop up.

Ctrl+Alt+L -> Show the Solution Explorer.


Ctrl + .

To include a missing library.


F7 and Shift+F7 to switch between designer/code view

Ctrl+Break to stop a build.

Great for those "oh, I realized this won't compile and I don't want to waste my time" moments.

Alt+Enter opens the resharper smart tag

Bookmark ShortCuts

Ctrl+K Ctrl+K to place a bookmark

Ctrl+K Ctrl+N to go to next bookmark

Ctrl+K Ctrl+P to go to previous bookmark

The refactor shortcuts.

Each starts with Ctrl+R.

Follow it with Ctrl+R for rename. Ctrl+M for extract method. Ctrl+E for encapsulate field.


Ctrl+Shift+V paste / cycle through the clipboard ring


Ctrl+- and Ctrl+Shift+-. But if you are a keyboard lover then go for Resharper


I like my code clean and arranged so my favorite keyboard shortcuts are the following:

Ctrl+K,D - Format document

Ctrl+K,F - Format selected code

Ctrl+E,S - Show white spaces

Ctrl+L - Cut line

Alt+Enter - Insert line below


The ones I use all the time:

  • ctrl+] Matching Brace

  • ctrl+shift+] Select to the end of brace

  • ctrl+shift+q Untabify

  • ctrl+k,ctrl+c comment out the currently selected block

  • ctrl+k,ctrl+u uncomment out the currently selected block

  • alt+mouse move vertical selection

  • ctrl+alt+x toolbox

  • ctrl+shift+b build


Here are my favourite debugging keyboard shortcuts:

  • F5 : start debugger / run to next breakpoint
  • Shift+F5 : stop debugging
  • F10 : step over next statement
  • F11 : step into next statement
  • Ctrl+F10: run to the cursor location
  • F9 : add or remove breakpoint

Ctrl+K then Ctrl+H to add a line of code to the built in task/todo list

(Ctrl+Alt+K). Very handy!


VS 2008

  1. Ctrl+E,D : Format Code

  2. Ctrl+M,O : Collapse To Definitions

  3. Ctrl+Z : Undo :)

  4. F9: Breakpoint

  5. Ctrl+Shift+F9 : Delete All Breakpoints


One that I use often but not many other people do is:

Shift + Alt + F10 then Enter

If you type in a class name like Collection<string> and do not have the proper namespace import then this shortcut combination will automatically insert the import (while the carret is immediately after the '>').

Update:

An equivalent shortcut from the comments on this answer (thanks asterite!):

Ctrl + .

Much more comfortable than my original recommendation.


Here's a link to a list of Shortcuts I find usefull (VS2003) but some still apply,

My favorite being F12 and Ctrl+- to navigate to the declaration and back


If 'Favorite' is measured by how often I use it, then:

F10 : Debug.StepOver

:)


Open a newline above Ctrl + Enter

Open a newline below Ctrl + Shift + Enter


Find and replace

  • Ctrl+F and Ctrl+H - Find, Find & replace, respectively

  • Ctrl+shift+F and Ctrl+shift+H - Find in files, Find & replace in files, respectively

"Find in files" has been an enormous productivity booster for me. Rather than jump to each result one by one, it just shows you a list of results in your entire project or solution. It makes it very simple to find sample code, or see if a function is used anywhere.


Ctrl+M, O. Can collapse and expand all sections of code in a particular file.


Snippets

Each snippet has a shortcut that you can access by typing a word then tab. The one I use the most is for a standard property definition; just type property then tab.


Haven't seen this one ...

Ctrl + Up

Ctrl + Down

Scrolls the window without moving the cursor.


One that other editors should take up: Ctrl+C with nothing selected will copy the current line.

Most other editors will do nothing. After copying a line, pasting will place the line before the current one, even if you're in the middle of the line. Most other editors will start pasting from where you are, which is almost never what you want.

Duplicating a line is just: Hold Ctrl, press c, then v. (Ctrl+C, Ctrl+V)


For me, it's nothing to do about auto completing code, matching parenthesis or showing some fancy tool panel. Instead, it's just about letting me see the code.

With all the panels surrounding you, the area you use to actually write code becomes too small.

In this cases, Shift+Alt+Enter comes in to the rescue and gets the code window in focus in full screen mode. Hit it again, and you have all the panels back.


Good old Ctrl+Tab for flipping back and forth between open documents.

Visual Studio actually provides a very nice Ctrl+Tab implementation; I especially appreciate that the Ctrl+Tab document activation order is most-recently-used order, rather than simple "left-to-right" order, so that Ctrl+Tab (press once and release) can be used repeatedly to flip back and forth between the two most-recently-used documents, even when there are more than two documents open.


Ctrl + - and the opposite Ctrl + Shift + -.

Move cursor back (or forwards) to the last place it was. No more scrolling back or PgUp/PgDown to find out where you were.

This switches open windows in Visual Studio:

Ctrl + tab and the opposite Ctrl + Shift + tab


Select word: Ctrl+W

I can't live without that shortcut. Used over 100+ (or 200+) a day.


Ctrl+Shift+S // Save

Ctrl+Shift+B // Build


One that I use often but not many other people do is:

Shift + Alt + F10 then Enter

If you type in a class name like Collection<string> and do not have the proper namespace import then this shortcut combination will automatically insert the import (while the carret is immediately after the '>').

Update:

An equivalent shortcut from the comments on this answer (thanks asterite!):

Ctrl + .

Much more comfortable than my original recommendation.


Ctrl+I for incremental search


In debug mode, Alt * jumps to the current breakpoint, where execution is stopped.


"prop" and hit tab.. stubs out property for you...


I have two that I use a lot, the first is standard, the second you have to map:

Ctrl+A, Ctrl+E, F (Select All, Format Selection)

Ctrl+E, R (Remove Unused Usings and Sort)

Both help pay down the "cruft debt" early and often


Ctrl+R+T (Runs the current test)

Ctrl+R+A (Runs all tests in the project)


One that other editors should take up: Ctrl+C with nothing selected will copy the current line.

Most other editors will do nothing. After copying a line, pasting will place the line before the current one, even if you're in the middle of the line. Most other editors will start pasting from where you are, which is almost never what you want.

Duplicating a line is just: Hold Ctrl, press c, then v. (Ctrl+C, Ctrl+V)


If 'Favorite' is measured by how often I use it, then:

F10 : Debug.StepOver

:)


Ctrl+Shift+V paste / cycle through the clipboard ring


Here's a link to a list of Shortcuts I find usefull (VS2003) but some still apply,

My favorite being F12 and Ctrl+- to navigate to the declaration and back


Here are my favourite debugging keyboard shortcuts:

  • F5 : start debugger / run to next breakpoint
  • Shift+F5 : stop debugging
  • F10 : step over next statement
  • F11 : step into next statement
  • Ctrl+F10: run to the cursor location
  • F9 : add or remove breakpoint

Ctrl+] for matching braces and parentheses.

Ctrl+Shift+] selects code between matching parentheses.


Ctrl+M, Ctrl+O : collapse to definitions. I use it all the time together with #regions

(despite what Jeff says) to get an overview of the code on my screen.


By far the most useful (after Ctrl+Shift+B) are:

  • Ctrl+K, C - to Comment out selection

  • Ctrl+k, U - to Uncomment a selection

Ctrl + R + W to display whitespace (great for tab or space enforcement).

Also, holding down Alt while selecting with the mouse will create a rectangular region.


Ctrl+I for incremental search


Ctrl + Alt + E = Exception/Catch Settings and code snippets


What Ray said. Ctrl + ..

I really didn't like the smart tags (those little blue and red underscores that appear wanting to help you) until I found out that you don't need to waste time trying to hover the mouse over the exact pixel that gets the menu to show.

I think Ctrl + . to open the smart tag menu saves me about five minutes every day and reduces my blood pressure considerably.


Ctrl+F10

run to cursor when debugging. Looked for this for ages before I found the keyboard shortcut...


The TAB key for "snippets".

E.g. type try and then hit the tab key twice.

Results in:

try 
{           

}
catch (Exception)
{

    throw;
}

which you can then expand.

Full list of C# Snippets: http://msdn.microsoft.com/en-us/library/vstudio/z41h7fat.aspx


Ctrl+K, Ctrl+D // Auto-(Re)Format

See Also: Answer


Refresh javascript intellisense and code coloring.


ctrl+shift+J

I've found intellisense for Javascript to be flaky - this usually straightens it out.


Ctrl+Shift+8 - Backtracks go to previous "F12/ Go to definition"


Incremental Search - Ctrl + I

It's basically the find dialog box without the dialog box. Just start typing what you want to search for (look at the bottom status bar location to see what you've typed). Pressing Ctrl + I again or F3 searches for the next instance. Press Escape to quit. Starting a new search by pressing Ctrl + I twice repeats the last search.


Ctrl+ E + D : Format Document

Tip for teams: Set up agreed-on formatting options in Visual Studio (they are very flexible), then export the settings to a .settings file for each developer to import.

Now if all developers learn to autoformat everything, it will not only produce perfect formatting consistency throughout the project with no effort at all, but also greatly reduce annoying false differences in the diff tool when merging multiple check-ins to Source Control.

Oh, I enjoy good tools!


Ctrl+K, Ctrl+C Comment a block

Ctrl+K, Ctrl+U Uncomment the block



Ctrl+Shift+S // Save

Ctrl+Shift+B // Build


F7 and Shift+F7 to switch between designer/code view

Ctrl+Break to stop a build.

Great for those "oh, I realized this won't compile and I don't want to waste my time" moments.

Alt+Enter opens the resharper smart tag

Bookmark ShortCuts

Ctrl+K Ctrl+K to place a bookmark

Ctrl+K Ctrl+N to go to next bookmark

Ctrl+K Ctrl+P to go to previous bookmark

The refactor shortcuts.

Each starts with Ctrl+R.

Follow it with Ctrl+R for rename. Ctrl+M for extract method. Ctrl+E for encapsulate field.


Ctrl+[ (Move to corresponding })

Ctrl+Shift+V (Cycle clipboard)


I mapped all of the expand/collapse commands so that they can be used with the left and only so my right hand stays on my mouse.
Ctrl + E, Ctrl + E toggles expansion,Ctrl + E, Ctrl + D collapses all to definitions, Ctrl + E, Ctrl + A toggles all outlining.


Ctrl+Alt+P -> Attach to process


Ctrl+C, Ctrl+V to duplicate the current line

Ctrl+L to delete the current line

Ctrl+F3 to search for the current selection

Ctrl+K, Ctrl+K to create a bookmark (which are useful)

Ctrl+K, Ctrl+N to go to the next bookmark

And, here is something even more interesting:
Press Ctrl+/ to put the cursor into a box where you can type commands.

For example, Pressing Ctrl+/ and type ">of ", now start typing the name of a file in your project, and it will autocomplete. This is a very fast way to open files in the current solution.


Ctrl+M, Ctrl+O : collapse to definitions. I use it all the time together with #regions

(despite what Jeff says) to get an overview of the code on my screen.


Ctrl+K then Ctrl+H to add a line of code to the built in task/todo list

(Ctrl+Alt+K). Very handy!


Open a file without using the mouse:

CTRL + ALT + A (opens command window) Followed by >open somedoc

I didn't see this one yet. Can't believe how many cool shortcuts have been posted here!


Use Emacs-like keybinding, it's TAB :P


Haven't seen this one ...

Ctrl + Up

Ctrl + Down

Scrolls the window without moving the cursor.


Ctrl+C, Ctrl+V to duplicate the current line

Ctrl+L to delete the current line

Ctrl+F3 to search for the current selection

Ctrl+K, Ctrl+K to create a bookmark (which are useful)

Ctrl+K, Ctrl+N to go to the next bookmark

And, here is something even more interesting:
Press Ctrl+/ to put the cursor into a box where you can type commands.

For example, Pressing Ctrl+/ and type ">of ", now start typing the name of a file in your project, and it will autocomplete. This is a very fast way to open files in the current solution.


Stock Visual Studio? F12 - Edit.GoToDefinition.

Having DevExpress' Refactor! installed means that Ctrl + ` is my all-time fave, though ;)


Ctrl+M, Ctrl+L will expand every collapsed bit of code. It is the opposite of Ctrl+M, Ctrl+O


Ctrl+- and Ctrl+Shift+-

Alt+D, P Attach the debugger to the application.

(first letter of any application you want to debug, works most of the time)

Ctrl+Shift+F

Ctrl+I (incremental seach)


One that I use often but not many other people do is:

Shift + Alt + F10 then Enter

If you type in a class name like Collection<string> and do not have the proper namespace import then this shortcut combination will automatically insert the import (while the carret is immediately after the '>').

Update:

An equivalent shortcut from the comments on this answer (thanks asterite!):

Ctrl + .

Much more comfortable than my original recommendation.


Save LOTS of time copy and cutting:

  • Ctrl+C with no selection in the line: copies the whole line

  • Ctrl+X with no selection - cuts the whole line

F7 and Shift+F7 to switch between designer/code view

Ctrl+Break to stop a build.

Great for those "oh, I realized this won't compile and I don't want to waste my time" moments.

Alt+Enter opens the resharper smart tag

Bookmark ShortCuts

Ctrl+K Ctrl+K to place a bookmark

Ctrl+K Ctrl+N to go to next bookmark

Ctrl+K Ctrl+P to go to previous bookmark

The refactor shortcuts.

Each starts with Ctrl+R.

Follow it with Ctrl+R for rename. Ctrl+M for extract method. Ctrl+E for encapsulate field.


Ctrl + , for 'Navigate To' window (link)


Alt + B + U - Build the current project.


Ctrl+R+T (Runs the current test)

Ctrl+R+A (Runs all tests in the project)


Not a keyboard shortcut, but with your mouse, you can use forward and backwards buttons on your mouse to go to previous locations in your code and return to your current location.


Ctrl+- and Ctrl+Shift+-

Alt+D, P Attach the debugger to the application.

(first letter of any application you want to debug, works most of the time)

Ctrl+Shift+F

Ctrl+I (incremental seach)


Ctrl+Shift+B - Build


Shift+ESC

This hides/closes any of the 'fake window' windows in Visual Studio. This includes things like the Solution Explorer, Object Browser, Output Window, Immediate window, Unit Test Windows etc. etc. and still applies whether they're pinned, floating, dockable or tabbed.

Shortcut into a window (e.g. Ctrl + Alt + L or Ctrl + Alt + I) do what you need to do, and Shift + Esc to get rid of it. If you don't get rid of it, the only way to give it focus again is to use the same keyboard shortcut (or the mouse, which is what we're trying to avoid....)

Once you get the hang of it, it's immensely useful.


Grrr....The amount of times of hit Ctrl + F4 to close the 'window' only to see my current code window close was insane before I found this, now it only happens occasionally..


People have mentioned Ctrl+C and Ctrl+V to paste a line when nothing is selected but I use Ctrl+X to move lines of code regularly.


Open a file without using the mouse:

CTRL + ALT + A (opens command window) Followed by >open somedoc

I didn't see this one yet. Can't believe how many cool shortcuts have been posted here!


Use Emacs-like keybinding, it's TAB :P


Ctrl+K, Ctrl+D // Auto-(Re)Format

See Also: Answer


Find and replace

  • Ctrl+F and Ctrl+H - Find, Find & replace, respectively

  • Ctrl+shift+F and Ctrl+shift+H - Find in files, Find & replace in files, respectively

"Find in files" has been an enormous productivity booster for me. Rather than jump to each result one by one, it just shows you a list of results in your entire project or solution. It makes it very simple to find sample code, or see if a function is used anywhere.


Ctrl+R+T (Runs the current test)

Ctrl+R+A (Runs all tests in the project)


Ctrl+Shift+S // Save

Ctrl+Shift+B // Build


Simple one. F8 : Go to next build error.

Found that now it will work in any sort of list window (the ones that cluster together at the bottom usually.


By usage, the pair:

  • Ctrl+Enter: insert blank line above the current line.
  • Ctrl+Shift+Enter: insert blank line below the current line.

For me, it's nothing to do about auto completing code, matching parenthesis or showing some fancy tool panel. Instead, it's just about letting me see the code.

With all the panels surrounding you, the area you use to actually write code becomes too small.

In this cases, Shift+Alt+Enter comes in to the rescue and gets the code window in focus in full screen mode. Hit it again, and you have all the panels back.


People have mentioned Ctrl+C and Ctrl+V to paste a line when nothing is selected but I use Ctrl+X to move lines of code regularly.


Ctrl+K, Ctrl+D // Auto-(Re)Format

See Also: Answer


Alt+Shift+arrow keys(,,,)

This allow you to select things in a block. Like you could select all of the "int" in the block and then search and replace to double for example.

**int** x = 1;
**int** y = 2;
**int** z = 3;

The TAB key for "snippets".

E.g. type try and then hit the tab key twice.

Results in:

try 
{           

}
catch (Exception)
{

    throw;
}

which you can then expand.

Full list of C# Snippets: http://msdn.microsoft.com/en-us/library/vstudio/z41h7fat.aspx


I am surprised not to find this one on the list as I use it all the time:

Ctrl + K, Ctrl + M - Implement method stub.

Write a call to a non-existent method, and then use that shortcut to create the method in the right place, with the right parameters and return value, but with a method body that just throws a NotImplementedException.

Great for top-down coding.


Open and set focus in Solution Explorer: Ctrl+Alt+L


F7 toggles from design view to code view.


If you install Visual Assist X, which I highly recommend you do, these are useful:

  • Alt+O: Toggle current document between header/implementation (.h/.cpp)

  • Alt+G: Go to definition/declaration


Ctrl + M, L - Expands all regions


If you have your keyboard settings set to the "Visual C# 2005" setting, the window switching and text editing chords are excellent. You hit the first combination of Ctrl + Key, then release and hit the next letter.

  • Ctrl+E, C: Comment Selected Text

  • Ctrl+E, U: Uncomment Selected Text

  • Ctrl+W, E: Show Error List

  • Ctrl+W, J: Show Object Browser

  • Ctrl+W, S: Show Solution Explorer

  • Ctrl+W, X: Show Toolbox

I still use F4 to show the properties pane so I don't know the chord for that one.

If you go to the Tools > Customise menu option and press the Keyboard button, it gives you a list of commands you can search to see if a shortcut is available, or you can select the "Press Shortcut Keys:" textbox and test shortcut keys you want to assign to see if they conflict.

Addendum: I just found another great one that I think I'll be using quite frequently: Ctrl+K, S

pops up an intellisense box asking you what you would like to surround the selected text with. It's exactly what I've needed all those times I've needed to wrap a block in a conditional or a try/catch.


Select word: Ctrl+W

I can't live without that shortcut. Used over 100+ (or 200+) a day.


Ctrl+I for incremental search


CTRL + Alt +

This causes the list of open files to pop open in the upper right corner of the editor window. The cool thing is that it is searchable so you can leave go of the keys and start typing the file name to shift the focus to that file. Very handy when you have zillions of files open.


F7 to build and then F8 to go to the errors and warnings one by one.


Ctrl + BP (Previous bookmark), Ctrl + BN (Next bookmark)


I think Ctrl + K + D is definitely my favourite. I use it more than any other shortcuts. It helps to format the document according to the indentation and code formatting settings specified by us.


Ctrl+Shift+V multiple times cycles through the clipboard ring.



Ctrl+Shift+R Tools.RecordTemporaryMacro (again to stop recording)

Ctrl+Shift+P Tools.RunTemporaryMacro

Beats the heck out of trying to work out a regexp search and replace!


Ctrl+Shift+S // Save

Ctrl+Shift+B // Build


Shift+ESC

This hides/closes any of the 'fake window' windows in Visual Studio. This includes things like the Solution Explorer, Object Browser, Output Window, Immediate window, Unit Test Windows etc. etc. and still applies whether they're pinned, floating, dockable or tabbed.

Shortcut into a window (e.g. Ctrl + Alt + L or Ctrl + Alt + I) do what you need to do, and Shift + Esc to get rid of it. If you don't get rid of it, the only way to give it focus again is to use the same keyboard shortcut (or the mouse, which is what we're trying to avoid....)

Once you get the hang of it, it's immensely useful.


Grrr....The amount of times of hit Ctrl + F4 to close the 'window' only to see my current code window close was insane before I found this, now it only happens occasionally..


Ctrl+K then Ctrl+H to add a line of code to the built in task/todo list

(Ctrl+Alt+K). Very handy!


F7 toggles from design view to code view.


F7 to build and then F8 to go to the errors and warnings one by one.


F9: toggle and un-toggle breakpoints!


I am surprised not to find this one on the list as I use it all the time:

Ctrl + K, Ctrl + M - Implement method stub.

Write a call to a non-existent method, and then use that shortcut to create the method in the right place, with the right parameters and return value, but with a method body that just throws a NotImplementedException.

Great for top-down coding.


Ctrl+Shift+B - Build


Ctrl+Shift+F

Good old Find In Files.


Shift+ESC

This hides/closes any of the 'fake window' windows in Visual Studio. This includes things like the Solution Explorer, Object Browser, Output Window, Immediate window, Unit Test Windows etc. etc. and still applies whether they're pinned, floating, dockable or tabbed.

Shortcut into a window (e.g. Ctrl + Alt + L or Ctrl + Alt + I) do what you need to do, and Shift + Esc to get rid of it. If you don't get rid of it, the only way to give it focus again is to use the same keyboard shortcut (or the mouse, which is what we're trying to avoid....)

Once you get the hang of it, it's immensely useful.


Grrr....The amount of times of hit Ctrl + F4 to close the 'window' only to see my current code window close was insane before I found this, now it only happens occasionally..


Ctrl+- and Ctrl+Shift+-. But if you are a keyboard lover then go for Resharper


Ctrl+Shift+V paste / cycle through the clipboard ring


Not a keyboard shortcut, but with your mouse, you can use forward and backwards buttons on your mouse to go to previous locations in your code and return to your current location.


Ctrl+Shift+8 - Backtracks go to previous "F12/ Go to definition"


Hopefully this hasn't already been posted, apologies if so. I've just come across a useful keyboard shortcut in Visual Studio 2008. With the QuickWatch window open, highlight a row with a string value in it and hit Space Bar. The text visualiser window will appear with the value in it.

I have found it quite useful for checking jQuery innerText values as the QuickWatch window by default is too small to show longer strings fully.


The combination Ctrl+U and Ctrl+Shift+U for converting a block of characters to all upper/lower case.


I have two that I use a lot, the first is standard, the second you have to map:

Ctrl+A, Ctrl+E, F (Select All, Format Selection)

Ctrl+E, R (Remove Unused Usings and Sort)

Both help pay down the "cruft debt" early and often


Ctrl + K, D to auto format code.


Expand Smart Tag (Resolve Menu): Ctrl + . (period)

Expands the tag that shows when you do things like rename an identifier.


Hmmm, nobody said F1 for help.

Could it be that Google is faster and better for getting at the information that you need.


Simple one. F8 : Go to next build error.

Found that now it will work in any sort of list window (the ones that cluster together at the bottom usually.


If 'Favorite' is measured by how often I use it, then:

F10 : Debug.StepOver

:)


I like Ctrl+M, Ctrl+M. To expand/collapse the current code block.


Another useful Find short key sequence is Ctrl (+ Shift) F --> ALT C --> ALT W for switching between exact and fuzzy searches.


Ctrl+K, Ctrl+C Comment a block

Ctrl+K, Ctrl+U Uncomment the block


Ctrl+Shift+R Tools.RecordTemporaryMacro (again to stop recording)

Ctrl+Shift+P Tools.RunTemporaryMacro

Beats the heck out of trying to work out a regexp search and replace!


What Ray said. Ctrl + ..

I really didn't like the smart tags (those little blue and red underscores that appear wanting to help you) until I found out that you don't need to waste time trying to hover the mouse over the exact pixel that gets the menu to show.

I think Ctrl + . to open the smart tag menu saves me about five minutes every day and reduces my blood pressure considerably.


Alt+Shift+ Arrow keys() or mouse moving = Block/Column selection

comes really handy


Here is a list that I use frequently:

Ctrl + I: for progressive search. If you don't type anything after I, and keep pressing I (holding the Ctrl key down), it will search the last item you had searched. Ctrl + Shift + I will reverse search. You might also want to use F3 (and Shift + F3) once some search string is entered.

Ctrl + K Ctrl + C: For commenting highlighted region. If nothing is highlighted, current line will be commented. Naturally, you can just hold Ctrl and press K, C in succession.

Ctrl + K Ctrl + U: For uncommenting highlighted region. Works like above.

Ctrl + /: Will take the cursor to the small search box on top. You can type ">of filename" (without the quotes) to open a file. Very useful if your project contains multiple files.

Ctrl + K Ctrl + K: Will bookmark the current line. This is useful if you want to look at some other part of code for a moment and come back to where you were.

Ctrl + K Ctrl + N: Will take you to the next bookmark, if there are more than one.

Ctrl + -: Will take the cursor to its previous location

Ctrl + Shift + -: Will take the cursor to its next location (if it exists)

Ctrl + Shift + B: Build your project

Ctrl + C: Although this does the usual copy, if nothing is highlighted, it copies the current line. Same for Ctrl + X (for cut)

Ctrl + Space: Autocomplete using IntelliSense

Ctrl + ]: Will take you to the matching brace. Works with all kinds of braces: '(', '{', '['. Useful for big blocks.

F12: Will take you to the function definition/variable definition.

Alt + P + P: Will open up project properties. Although not many use this, it useful if you want to quickly change the command line arguments to your program.

F5: To start debugging

Shift + F5: To stop debugging

While debugging, you can use Ctrl + Alt + Q to add a quick watch. Other debugging shortcuts can be found in the debug drop down menu.


Ctrl + R + W to display whitespace (great for tab or space enforcement).

Also, holding down Alt while selecting with the mouse will create a rectangular region.


Ctrl+R+T (Runs the current test)

Ctrl+R+A (Runs all tests in the project)


F7 to build and then F8 to go to the errors and warnings one by one.


Good old Ctrl+Tab for flipping back and forth between open documents.

Visual Studio actually provides a very nice Ctrl+Tab implementation; I especially appreciate that the Ctrl+Tab document activation order is most-recently-used order, rather than simple "left-to-right" order, so that Ctrl+Tab (press once and release) can be used repeatedly to flip back and forth between the two most-recently-used documents, even when there are more than two documents open.


Ctrl+F10

run to cursor when debugging. Looked for this for ages before I found the keyboard shortcut...


The ones I use all the time:

  • ctrl+] Matching Brace

  • ctrl+shift+] Select to the end of brace

  • ctrl+shift+q Untabify

  • ctrl+k,ctrl+c comment out the currently selected block

  • ctrl+k,ctrl+u uncomment out the currently selected block

  • alt+mouse move vertical selection

  • ctrl+alt+x toolbox

  • ctrl+shift+b build


Stock Visual Studio? F12 - Edit.GoToDefinition.

Having DevExpress' Refactor! installed means that Ctrl + ` is my all-time fave, though ;)


In debug mode, Alt * jumps to the current breakpoint, where execution is stopped.


If you have your keyboard settings set to the "Visual C# 2005" setting, the window switching and text editing chords are excellent. You hit the first combination of Ctrl + Key, then release and hit the next letter.

  • Ctrl+E, C: Comment Selected Text

  • Ctrl+E, U: Uncomment Selected Text

  • Ctrl+W, E: Show Error List

  • Ctrl+W, J: Show Object Browser

  • Ctrl+W, S: Show Solution Explorer

  • Ctrl+W, X: Show Toolbox

I still use F4 to show the properties pane so I don't know the chord for that one.

If you go to the Tools > Customise menu option and press the Keyboard button, it gives you a list of commands you can search to see if a shortcut is available, or you can select the "Press Shortcut Keys:" textbox and test shortcut keys you want to assign to see if they conflict.

Addendum: I just found another great one that I think I'll be using quite frequently: Ctrl+K, S

pops up an intellisense box asking you what you would like to surround the selected text with. It's exactly what I've needed all those times I've needed to wrap a block in a conditional or a try/catch.


Ctrl+[ (Move to corresponding })

Ctrl+Shift+V (Cycle clipboard)


Use Emacs-like keybinding, it's TAB :P


Ctrl+- and Ctrl+Shift+-

Alt+D, P Attach the debugger to the application.

(first letter of any application you want to debug, works most of the time)

Ctrl+Shift+F

Ctrl+I (incremental seach)


Turn line wrapping on and off

Ctrl+E, Ctrl+W

Sometimes you want to see the flow of the code with all of your indents in place; sometimes you need to see all 50 attributes in a GridView declaration. This lets you easily switch back and forth.


Ctrl+Shift+R Tools.RecordTemporaryMacro (again to stop recording)

Ctrl+Shift+P Tools.RunTemporaryMacro

Beats the heck out of trying to work out a regexp search and replace!


Showing hidden windows

  • ctrl+alt+L + Solution explorer

  • ctrl+alt+S + Server explorer

  • ctrl+alt+O + Output

  • ctrl+alt+X + Toolbox

  • ctrl+shift+W, 1 + Watch

  • ctrl+\, E + Error list

  • ctrl+shift+C + Class view

I like to use all my screen real estate for code and have everything else hidden away. These shortcuts keep these windows handy when I need them, so they can be out of the way the rest of the time.


Ctrl+Space, Visual Studio gives the possible completions.


Ctrl+Shift+8 - Backtracks go to previous "F12/ Go to definition"


Expand Smart Tag (Resolve Menu): Ctrl + . (period)

Expands the tag that shows when you do things like rename an identifier.


Ctrl+Shift+F4 to close all windows. You have to map it yourself:

Instructions:

  • In Visual Studio, go to Tool | Options
  • Under Environment select Keyboard
  • In Show commands containing, enter Window.CloseAllDocuments. You should get a single entry in the listbox below it
  • Put the cursor in Press shortcut keys and press Ctrl+Shift+F4.
  • Click OK

Credit to Kyle Baley at codebetter.com. I modified his example to use shift instead of alt because it was easier on my hands.


Ctrl+Shift+B - Build


Well, if you're really

always up for leaving my hands on the keyboard and away from the mouse!

Than you should go here

It's not really my favorite, it's just everything!

A shortcut a day will keep the mouse away.


There are some great tips and trips and shortcuts on Sara Ford's blog.


Ctrl+[ (Move to corresponding })

Ctrl+Shift+V (Cycle clipboard)


Stock Visual Studio? F12 - Edit.GoToDefinition.

Having DevExpress' Refactor! installed means that Ctrl + ` is my all-time fave, though ;)


F7 and Shift+F7 to switch between designer/code view

Ctrl+Break to stop a build.

Great for those "oh, I realized this won't compile and I don't want to waste my time" moments.

Alt+Enter opens the resharper smart tag

Bookmark ShortCuts

Ctrl+K Ctrl+K to place a bookmark

Ctrl+K Ctrl+N to go to next bookmark

Ctrl+K Ctrl+P to go to previous bookmark

The refactor shortcuts.

Each starts with Ctrl+R.

Follow it with Ctrl+R for rename. Ctrl+M for extract method. Ctrl+E for encapsulate field.


I hate closing the extra tabs when I use "Start Debugging" on ASP.NET apps. Instead, I usually use "Start without Debugging" (Ctrl+F5).

If I end up needing to debug, I use Ctrl+Alt+P (Attach to Process)

and choose WebDev.WebServer.exe. Then I'm still on my previous page and I only have one tab open.


Control+Apostrophe.

Oh wait, that was after I remapped it away from that god-awkward Alt+Shift+F10 or whatever it was.

When you remap options to help bind this away from it's original hard to hit shortcut, it becomes a lot lot more useful.


Ctrl+Shift+F4 to close all windows. You have to map it yourself:

Instructions:

  • In Visual Studio, go to Tool | Options
  • Under Environment select Keyboard
  • In Show commands containing, enter Window.CloseAllDocuments. You should get a single entry in the listbox below it
  • Put the cursor in Press shortcut keys and press Ctrl+Shift+F4.
  • Click OK

Credit to Kyle Baley at codebetter.com. I modified his example to use shift instead of alt because it was easier on my hands.


I don't think that any shortcut is remaining for me to mention so let me mention a shortcut that I would love Visual Studio to have :-) One shortcut that I really miss and that is present in Eclipse is "Open Resource" (Ctrl + Shift + S) which allows you to type in a file name and the IDE displays the files matching it. Really useful when you are working with bid code bases!


Ctrl + - and the opposite Ctrl + Shift + -.

Move cursor back (or forwards) to the last place it was. No more scrolling back or PgUp/PgDown to find out where you were.

This switches open windows in Visual Studio:

Ctrl + tab and the opposite Ctrl + Shift + tab


My favorite: F12 (go to definition) and Shift+F12 (find references).

The latter is useful with F8 (go to next result).

Ctrl+- and Ctrl+Shift+- are mapped to my mouse's back and forwards buttons.

Ctrl+. is useful too, especially for adding event handlers and "using" statements.


Ctrl + M, L - Expands all regions


Stock Visual Studio? F12 - Edit.GoToDefinition.

Having DevExpress' Refactor! installed means that Ctrl + ` is my all-time fave, though ;)


Here's a link to a list of Shortcuts I find usefull (VS2003) but some still apply,

My favorite being F12 and Ctrl+- to navigate to the declaration and back


"prop" and hit tab.. stubs out property for you...


Ctrl + K + C - set current selected code to be comments Ctrl + K + U - set current selected comments to be code


F9: toggle and un-toggle breakpoints!


Ctrl+Shift+S

Save all changed files. saved me quite a few times.


Ctrl+M, Ctrl+L will expand every collapsed bit of code. It is the opposite of Ctrl+M, Ctrl+O


Ctrl+Shift+Alt+B Rebuild Solution.

Ctrl+R, Ctrl+T Debug Tests in Current Context


VS 2008

  1. Ctrl+E,D : Format Code

  2. Ctrl+M,O : Collapse To Definitions

  3. Ctrl+Z : Undo :)

  4. F9: Breakpoint

  5. Ctrl+Shift+F9 : Delete All Breakpoints


Alt + B + U - Build the current project.


When the IntelliSense drop down is displayed, holding down Ctrl turns the list semi-transparent so you can see what is hidden behind it :)


If you have your keyboard settings set to the "Visual C# 2005" setting, the window switching and text editing chords are excellent. You hit the first combination of Ctrl + Key, then release and hit the next letter.

  • Ctrl+E, C: Comment Selected Text

  • Ctrl+E, U: Uncomment Selected Text

  • Ctrl+W, E: Show Error List

  • Ctrl+W, J: Show Object Browser

  • Ctrl+W, S: Show Solution Explorer

  • Ctrl+W, X: Show Toolbox

I still use F4 to show the properties pane so I don't know the chord for that one.

If you go to the Tools > Customise menu option and press the Keyboard button, it gives you a list of commands you can search to see if a shortcut is available, or you can select the "Press Shortcut Keys:" textbox and test shortcut keys you want to assign to see if they conflict.

Addendum: I just found another great one that I think I'll be using quite frequently: Ctrl+K, S

pops up an intellisense box asking you what you would like to surround the selected text with. It's exactly what I've needed all those times I've needed to wrap a block in a conditional or a try/catch.


My favorite: F12 (go to definition) and Shift+F12 (find references).

The latter is useful with F8 (go to next result).

Ctrl+- and Ctrl+Shift+- are mapped to my mouse's back and forwards buttons.

Ctrl+. is useful too, especially for adding event handlers and "using" statements.


Alt+Shift+arrow keys(,,,)

This allow you to select things in a block. Like you could select all of the "int" in the block and then search and replace to double for example.

**int** x = 1;
**int** y = 2;
**int** z = 3;

Cutting and pasting lines

Everyone knows Ctrl + X and Ctrl + C for cutting/copying text; but did you know that in VS you don't have to select the text first if you want to cut or copy a single line? If nothing is selected, the whole line will be cut or copied.


Ctrl+Shift+V paste / cycle through the clipboard ring


I'm a big fan of Ctrl + D + Q to open quickwatch while debugging.


Incremental Search - Ctrl + I

It's basically the find dialog box without the dialog box. Just start typing what you want to search for (look at the bottom status bar location to see what you've typed). Pressing Ctrl + I again or F3 searches for the next instance. Press Escape to quit. Starting a new search by pressing Ctrl + I twice repeats the last search.


Ctrl+Shift+F

Good old Find In Files.


Ctrl+K then Ctrl+H to add a line of code to the built in task/todo list

(Ctrl+Alt+K). Very handy!


Some handy ones that I use often are:

Ctrl+J -> Forces Intellisence to pop up.

Ctrl+Alt+L -> Show the Solution Explorer.


Ctrl + W for selecting the current word


Ctrl + .

To include a missing library.


If you install Visual Assist X, which I highly recommend you do, these are useful:

  • Alt+O: Toggle current document between header/implementation (.h/.cpp)

  • Alt+G: Go to definition/declaration


Ctrl + W for selecting the current word


One that other editors should take up: Ctrl+C with nothing selected will copy the current line.

Most other editors will do nothing. After copying a line, pasting will place the line before the current one, even if you're in the middle of the line. Most other editors will start pasting from where you are, which is almost never what you want.

Duplicating a line is just: Hold Ctrl, press c, then v. (Ctrl+C, Ctrl+V)


Format document

   Ctrl+K, Ctrl+D
  1. On an aspx page, this takes care of properly indenting all of your markup and ensures that everything is XHTML compliant (adds quotes to attributes, corrects capitalization, closes self-closing tags). I find that this makes it much easier to find mismatched tags and to make sure that my markup makes sense. If you don't like how it's indenting, you can control which tags go on their own line and how much space they get around them under Tools/Options/Text Editor/HTML/Format/Tag Specific Options.

  2. In your C# or VB code, this will correct any capitalization or formatting issues that didn't get caught automatically.

  3. For CSS files, you can choose compact (one definition per line), semi-expanded, or expanded (each rule on its own line); and you can choose how it handles capitalization.


Incremental Search - Ctrl + I

It's basically the find dialog box without the dialog box. Just start typing what you want to search for (look at the bottom status bar location to see what you've typed). Pressing Ctrl + I again or F3 searches for the next instance. Press Escape to quit. Starting a new search by pressing Ctrl + I twice repeats the last search.


There are some great tips and trips and shortcuts on Sara Ford's blog.


Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to keyboard-shortcuts

Collapse all methods in Visual Studio Code Is there a keyboard shortcut (hotkey) to open Terminal in macOS? Jupyter/IPython Notebooks: Shortcut for "run all"? Any way (or shortcut) to auto import the classes in IntelliJ IDEA like in Eclipse? How do I duplicate a line or selection within Visual Studio Code? How do I search for files in Visual Studio Code? OS X Terminal shortcut: Jump to beginning/end of line window.close() doesn't work - Scripts may close only the windows that were opened by it Comment shortcut Android Studio Column/Vertical selection with Keyboard in SublimeText 3