views:

3204

answers:

28

I know a few that I like.

ALT+SHIFT+F10 then ENTER which automatically adds the "using" at the top if i'm referencing an object that I haven't put the namespace in for yet.

CTRL + + or CTRL + -

Which moves you back and forward to which file and method you are/were looking at which is very handy when used in combination with "Go To Definition" or "Find All References".

Are there any other awesome ones I should know about?

+6  A: 

Here is something I use from times to times from Coding Horror : Visual Studio .NET 2005 Keyboard Shortcuts

Pascal Paradis
+2  A: 

CTRL + E then C to comment the selected text

CTRL + E then C to uncomment

CTRL + E then F to automatically format the selected code according to VS style guides

Jonas Oberschweiber
This does not work on my system. On my system Ctrl+E followed by C opens up the ReSharper Code Cleanup window.
Sakkle
Doesnt work for me either.
Ronnie Overby
+7  A: 

ALT+F4 closes the program.

Thomas Owens
Creativity deserves a vote :D
Wagner Danda da Silva
+2  A: 

Ctrl + I is the shortcut of incremental search.
Ctrl + Shift + I is reverse incremental (These two are probably the most awesome shortcuts in vs).
Ctrl + a + m + m collapses all the document.
Ctrl + m + m toggles expand collapse at the location of the pointer.
Ctrl + . on an identifier opens the refactoring menu on the item (When you change the name of an identifier, a parameter or a method and when you type something but the using statement is missing).
Ctrl + k + d automatically formats the whole file (to correct indentation and spacing, also works on markup, xml and stylesheets).

Serhat Özgel
+1  A: 

A couple I use frequently:

Hilight the section of code you want. Use the chord CTRL + K, C and all the entire hilighted portion will be commented out. Use the chord CTRL + K, U to then uncomment it.

Hold down SHIFT, then ALT and then you can "block select" text which will go down to the next (and subsequent lines), but not pick up the remainders of the following line.

Dillie-O
+14  A: 

I've found the Visual C# 2008 Keybinding Reference Poster produced by Microsoft very useful.

There is also one for VS 2005, of course.

AR
+2  A: 

There's Ctrl+K + Ctrl+C or Ctrl+U to comment/uncomment the selection. F12 to go to a definition and Ctrl+NumPad * to return to where you pressed F12. There's a command to go from source to header file (for the C/C++ people) but there's no equivalent to go to source from header, so I wrote my own in a plugin.

I'm sure I'll think of more as I code.

There's also Ctrl+] which highlights to the matching () or {}.

Skizz

Skizz
+1  A: 

Jonas, Actually CTRL E + U is used for uncomment, CTRL E + C for comment.

AndyMan
+3  A: 

Here're some that I use frequently:

  • Ctrl+Shift+U for uppercasing content
  • Alt+Drag for box selection of content
  • Ctrl+Click for whole word selection
  • Ctrl+B I have bound to build selected project (Build.BuildSelection), for larger solutions with a ton of projects in them

Boring but often used:

  • Ctrl+Space intellisense
  • F11 Step into
travis
+1  A: 

One of my personal favorites:

  • Ctl+ Alt + q gives you QuickWatch
wcm
+1  A: 

Ctrl-. is my favorite, particularly for automatically adding a using statement when necessary. Ctrl-Space and Ctrl-Shift-Space for autocomplete and parameter hints is nice too.

I remap Ctrl-W to close a window (matching a lot of other MDI and tabbed interface conventions) and Ctrl-Shift-P to 'Build Selection' which is really 'Build Project'

John Sheehan
+3  A: 

This actually is not a short cut but in the site:

http://blogs.msdn.com/saraford/

Sara Ford posts a lot of small tips about Visual Studio IDE.

Also one very important short cut Ctrl + S, save the current document and your job ;-)

jl23x
+1  A: 

ALT-D-P - attach to process

CTRL-M-M expand collapsed code blocks (boo using regions!)

jonezy
+1  A: 

As well as the previously mentioned C# keybindings poster, there is a Visual Basic 2008 poster and a Visual C++ 2008 poster.

The ones that I personally find the most useful are the following:

Ctrl + R + R: Refactor->Rename

Ctrl + L: Cut line

Ctrl + Shift + L: Delete current line, without placing it in the clipboard

Ctrl + Tab: Switch to last used tab (very useful for switching back and forth between two files)

Ctrl + W: Select current word

Ctrl + up arrow: scroll up one line, without moving caret.

Ctrl + down arrow: scroll down one line, without moving caret

Erik Öjebo
+25  A: 

Here are my most frequently used shortcuts. These are for the Visual Studio 2008 C# development settings, so may not work using General or VB.Net settings.

Building and Debugging

F6 Build

ALT + D, P Attach to process

ALT + D, P, N Attach to NUnit (unless notepad is open, :-))

Text Editor

CTRL + X Remove current line and place it on the clipboard

ALT + SHIFT + T Swap the current line with the line below it

CTRL + K, C Comment

CTRL + K, U Uncomment

CTRL + M, M Toggle Outlines

CTRL + M, 0 Collapse to Definitions

IDE

CTRL + ALT + L Show the Solution Explorer

F4 Show the Properties window

ALT + SHIFT + ENTER Full Screen

ALT + W, L Close all the open documents

ALT + F4 Go Home for the Day

CTRL + SHIFT + A Add new file

Refactoring

F2 Rename

ALT + SHIFT + F10 Open "Smart Tag" menu - Great for adding "usings" without typing.

SHIFT + F12 Find all References

F12 Find Definition

Brad Tutterow
I love the GO HOME for a DAY one. haha.
Scott
Add ctrl+i -> incremental search
andrecarlucci
For printing purposes, it would be nice to view the comment in a single page :)
orip
Paste this in your address bar. javascript:$("body").html($("#answer-21628").html()).css("text-align", "left");window.print();
Marko
A: 

Try to type "prop" and press twice [TAB] and you'll see someting cool. (at least for me)

nmiranda
A: 

Not sure if this works in VS08 but I like setting up some simple 'statement completions' using the Editor Gaget from Visual Studio 2005 Automation Samples (see link below). So for example I have setup:

** to be replaced with //TODO:
?? to be replaced with MessageBox.Show(

http://www.microsoft.com/downloads/details.aspx?FamilyId=79C7E038-8768-4E1E-87AE-5BBBE3886DE8&displaylang=en

the empirical programmer
+1  A: 

Bookmarks

Ctrl + K, K -- creates a bookmark

Ctrl + K, N -- navigates to next bookmark

Ctrl + K, P -- navigates to previous bookmark

Terrapin
+2  A: 

FYI, If you select different profiles when you first start Visual Studio then some of the key mappings will be different.

If you selected "Visual Basic development" your keys will be different from someone who selects "Visual C# development".

Even the run/build/debug keys can be different!

So you might as well post what profiles you're using.

chakrit
+2  A: 

Keep in mind that some of the VS mappings use different keystrokes for things; it helps to go into Tools>Options and find out the actual VS command that your shortcut is mapped to to ensure other people can set it up.

I absolutely love Ctrl + - (minus) and Ctrl + Shift + -.

Ctrl + - is mapped to View.NavigateBackwards and takes you to the last place your cursor was. Have you ever used F12 (Edit.GoToDefinition) on a method, then followed another method call, then ended up so far away from where you started that you can't get back? Ctrl + - will get you back.

Ctrl + Shift + - is View.NavigateForwards, and does the opposite. If you walk back up the call chain, then decide you need to go down again, this one suits your needs.

OwenP
+2  A: 

I find the following really useful:-

  • F12 - Go to definition
  • Shift-F12 - Find all references
  • Ctrl+Shift+8 - Go back to where you previously were
  • Ctrl+I - Incremental search (i.e. search like Firefox's)
  • Ctrl+Shift+I - Reverse incremental search (backwards from the caret)
  • Ctrl+Alt+L - Solution Explorer
  • Ctrl+Alt+S - Server Explorer
  • F4 - Properties
  • Shift+Esc - Kill the tool window you've got open
  • F6 - Compile (depending on config!)
  • F5 - Run (depending on config!)
kronoz
+1  A: 

CRTL-D .. places you in the find textbox of the 'standard' toolbar. Type '>' and you now can run a bunch of commands.

My favorite: ">of " then start typing a filename. It will provide a dropdown of matching files across the solution. (Using the file open dialog was my biggest gripe for solutions that span lots of directories, this flattens that nicely.)

You can also set a bp on a function by typing its name and hitting f9.

Steve Steiner
Or ">shell notepad", ">alias ..." et cetera. See http://msdn.microsoft.com/en-us/library/c3a0kd3x(VS.71).aspx
Jasper Bekkers
+1  A: 

I use viemu to let me use the Vi editor's modal editing style within Visual Studio.

I also depend heavily on Ctrl+j and Ctrl+space to display intellisense info.

Kevin Berridge
+1  A: 

Not really a shortcut but in code view you can drag&drop (or cut&paste) code on to the Toolbox. Then if you need that code again just double click it.

the empirical programmer
+1  A: 

Oddly I don't see that anyone has posted a couple of the ones I use very frequently:

  • CTRL + R CTRL + T - Debug currently scoped unit test
  • CTRL + R T - run the currently scoped unit test
ctacke
+2  A: 

Make your own awesome short cuts with this tool:

http://www.autohotkey.com/

OpenSource and fully customizable. It is Windows only, sadly.

Michiel
+2  A: 

Ctrl+Enter = Insert line above the current line

Ctrl+Shift+F9 = Clear all breakpoints

Also if, like me, you hate the popup window when using Ctrl+Tab you can fix it:

In keyboard customization reassign the keys to Window.NextDocumentWindow instead of Window.NextDocumentWindow_Nav_. Do the same for Ctrl+Shift+Tab and Window.PreviousDocumentWindow.

cantabilesoftware
+1  A: 

Shift+Esc to close current tool window and return to text editor. I use this after temporarily popping up the breakpoints window (Ctrl+Alt+B).

Ctrl+T transposes the letters on either side of the cursor. This might sound a bit pointless (did to me at first, anyway) but if you're like me and many of your compiler errors are due to character transpositions then it's surprisingly handy once you've internalized its use.

Ctrl+K, Ctrl+D reformats the entire document -- if you're working in C#, anyway. No real equivalent in C++, but Ctrl+K, Ctrl+F will reformat the selection, and this works well in conjunction with Shift+Ctrl+] if it's easy to get to the { or } of a sizeable scope. (This feature is supported way better in C#, but its C++ equivalent will at least sort out many common indentation problems.)

Ctrl+Shift+R starts or stops recording a temporary macro. Use Ctrl+Shift+P to run the result. It took me a bit of trial and error and practice to work out how best to use this, and it's not as good as the emacs equivalent, but it works well for a lot of repetetive ad-hoc fiddly editings. It's also very handy if you're trying to work out how to express in a macro something that you know how to do by hand using the UI.

brone