Click here to Skip to main content
Email Password   helpLost your password?

Introduction

A compendium of short cuts, tips and tricks, features, whatcha-may-callits for the Visual Studio .NET IDE.

I love Vim. And the power it gives is almost corrupting. Actually it is corrupting. Which is why I try to see if any editor provides all the functionality provided by Vim. Visual Studio .NET has quite a lot of useful options. Many of them are out there in the open in the menus but I did not see them for long until I went hunting for them. Some others are very obvious, but when I show them to some people, they are amazed that I can do that; so I have included some of those too. So here is a list of useful hints that I gathered. If you have any more, please do send them and I'll add them here with due recognition to the contributor. :-) By the way, I do not take credit for these hints but I will take credit for putting them together from various sources on the net.

1. Record and play temporary macro

Ctrl+Shift+R to record a new temporary macro. Press Ctrl+Shift+R to stop recording. Ctrl+Shift+P to play the recorded macro.

This works similar to *recording* in Vim. If you think you are going to be repeating a set of keyboard keys, then record them once and play them each time after.

2. Multiple copy/pastes

Ctrl+Shift+V cycles through the clipboard ring. You can copy/cut multiple times from one area of code, then go to another area and paste them one after another.

3. Drag and drop code snippets

The Toolbox (Ctrl+Alt+X) window has multiple tabs. You can drag and drop code onto this window and copy it elsewhere. Some tabs do not allow dropping code into them; those that allow will have the appropriate icon. The General tab works for me.

4. Previous cursor positions

Ctrl+- i.e. Ctrl + Hyphen. This cycles you through the code positions you visited.

Ctrl+Shift+- to navigate in the opposite direction.

5. Incremental search

To incrementally search for text as you type, first press Ctrl+i. Then type the word you want to search. Hit backspace to clear a character and enter to finish. Pressing F3 after this will work as usual, i.e. search for the next occurrence of previous search.

Ctrl+i - Ctrl+i works like F3.

6. Matching brace/comment/region/quote

Ctrl+] takes you to the matching brace. It also takes you to the matching comment, region or quote depending on what is at the cursor now.

7. Vertical block selection

Press Alt and then select the area you want with your mouse.

8. Closing/Showing support windows

There are a bunch of necessary/useful windows in the Visual Studio IDE like Properties (F4), Solution Explorer (Ctrl+Alt+L), Output Window (Ctrl+Alt+O), Task List (Ctrl+Alt+K) etc. However, they take up a lot of space. An easy way around this is to use the auto hide feature.

Open the window you want. Right click on its title and choose Auto Hide. The window will dock in whenever your mouse is not hovering over it.

9. Tab groups - group code editor windows

If you have many source code windows open, you can group them logically using tab groups. Right click the tab of the code window and choose New Horizontal Tab Group. This will move the window into a split window, allowing you to see both files. You can add more files to this new tab group and also move files back to the previous group by choosing Move To Previous Tab Group.

10. Track things you have to do with Task List

The Task List window (Ctrl+Alt+K) allows you to keep track of the things you have to do. Right click on the Task List window and choose Show Tasks|All to see a list of tasks. Ctrl+Shift+F12 to cycle through your list of tasks.

By default, comments marked with a TODO will appear in the task list.

11. Edit Task List Comment Tokens

You can add your own set of comment tokens (like the TODO comment token). Goto Tools|Options|Environment|Task List|Comment Tokens and make your changes. You can change the priority appearance of each comment token too.

12. Add Task List Shortcut

Add a shortcut to the task list with Ctrl+K, Ctrl+H. This will add the current line to the task list.

13. Auto-complete

Press Ctrl+Space or Alt+RightArrow to auto-complete the word. Intellisense suggestions may pop up a window if there is more than one possibility.

14. Intellisense suggestions window

Press Ctrl+Shift+Space to bring up the intellisense suggestions window. When giving parameters for functions, I often need to escape the suggestions window to check another part of code. To bring it back, I used to delete a comma and then type it again; but this is easier.

15. Word wrap

Ctrl+R Ctrl+R

or

Tools|Options|Text Editor|All Languages|General|Word Wrap

If you want to set this option for only one language, then choose the appropriate language instead of All Languages.

16. Line numbering

Tools|Options|Text Editor|All Languages|General|Line numbers.

If you want to set this option for only one language, then choose the appropriate language instead of All Languages.

17. Customizing Visual Studio's Code Generation Templates

Customizing Visual Studio's Code Generation Templates.

18. Default Shortcut keys

MSDN.

19. Favorites window

Your IDE also functions as a browser. To see your list of favorites, press Ctrl+Alt+F or choose View|Other Windows|Favorites.

20. Bookmarks

Bookmarks are available through Edit|Bookmarks. Bookmarks allow you to mark places in your code that you would want to come back to.

21. Code Formatting

22. Outlining

I like this feature that allows me to hide code that is irrelevant to what I'm currently working on.

23. Build and Debug

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralHow to open and close a Tool Window in VS 2005 (and beyond)
Suresh R Iyer
2:01 14 Jun '09  
One of the frustrations I have been having with VS 2005 has been the inability to access the "Auto Hide" toggle button (that is available in each of the tool windows) via the keyboard. I wanted a way to pin and unpin the tool windows using keyboard, as well as have a provision to hide the tool window.

More info here: Visual Studio .NET Shortcuts for Toggling Tool Windows[^]
GeneralMore tips.
prabir
8:10 26 May '09  
I have also been adding tips and tricks at my blog. You can check them at http://blog.prabir.me/page/Tips-and-Tricks.aspx
AnswerGetting Vi/Vim power from within Visual Studio
zcrar70
3:25 20 Dec '07  
If you find Vi/Vim's power corrupting, you might be tempted to actually achieve it (rather than emulating it) using ViEmu:

[http://ViEmu.com]

I'm not affiliated, but it's an amazing extension for Vi/Vim addicts using Visual Studio.
GeneralCodeWinPos
michaelmakuch
17:36 19 Jul '07  
Need to open .h files on the left and .cpp files on the right?
Try http://codewinpos.sourceforge.net
GeneralRe: CodeWinPos
kovarex
3:15 21 Oct '07  
It sounds nice, but it doesn't work
Questionintellisense with my code ?
ChrisRibe
6:40 13 Jun '07  
Hi, thanks for the great tips !

I was wondering, is it possible to make intellisense know about my custom asp classes ? It knows about the standard Response.Write, etc...

Is there a plugin I could use ??

Hummm if there are none maybe I could code one, that would rock !

Thanks again !
Chris
AnswerRe: intellisense with my code ?
Vikash Dubey
20:22 24 Jul '07  
Have you tried Visual Assist from wholetomato.com
GeneralRe: intellisense with my code ?
ChrisRibe
22:20 30 Jul '07  
Wow cool, thanks !!

Will try this out and give you my impressions.
Chris Big Grin
Questiontab position is not remebered
mikiunu
4:46 9 May '07  
Hi,

I have set the IDE to have two separate panes in the central area. The source files displayed in the upper part and tabs like: Error List, Breakpoints, Output, Find Symbol in the lower part.

Everytime I close the environment and start it again I can only see one pane which has both source files and additional tabs.

Is there any way to save the current tab configuration so that it can be restored to the closing position?


Thanks
Miki
AnswerRe: tab position is not remebered
Andrew Phillips
21:59 16 May '07  
VS is supposed to restore to the previous position of windows, but I too have noticed that sometimes windows are not restored correctly. This may have been improved with the service pack if you have not installed it yet.

Reading your post again it appears you might have your tool windows set as tabbed documents then you are using the "new tab group" which allows multiple groups of (MDI) documents. What you really need to do is right click the tab of the tool window (Error List etc) and select "Dockable" instead of "Tabbed Document", then you can dock the window anywhere.

Unfortunately you can't make a normal document window floating/dockable, only tool windows. This is something I have found annoying in all versions of VS (since I started with it in 4.2).


Andrew Phillips
http://hexedit.com
andrew @ hexedit.com

GeneralBlock select keyboard shortcut? [modified]
Ken Hadden
6:35 1 May '07  
Nice article.

Does anyone else think it's sad that the user community needs to provide this type of documentation? I mean the product has been around a long time. It's documentation should be a lot more straight-forward.

Anyway -- anyone know how to start block select with the keyboard?

I use that feature in Textpad (Ctrl+Shift+F8) a lot.



-- modified at 18:44 Tuesday 1st May, 2007
I'm editing this because I found out on my own :-> It turns out that you just hold Alt while you Shift+Arrow.
Simple... And to think all these years I've been pasting stuff into textpad just to use block select!


Thanks.
KHadden

GeneralRename
notbono
15:55 17 Apr '07  
Select and right click a variable or function. Then select "Rename" This will update other instances of the variable or function name as well as the selected without Find/Replace.
GeneralRe: Rename
K.L.K
15:15 15 Apr '08  
Or you can press F2 to avoid using the mouse.
GeneralBookmarks
dankoGreiner
1:10 14 Jul '06  
Bookmarks in VS 2005 cycle through entire solution which is very anoying, and i want to use bookmarks only on current document.

Any idea how to set 'bookmark scope'?

Thanx!

GeneralRe: Bookmarks
Peter Wucherer
23:42 18 Apr '07  

dankoGreiner wrote:
Bookmarks in VS 2005 cycle through entire solution which is very anoying, and i want to use bookmarks only on current document.

Any idea how to set 'bookmark scope'?

Thanx!

You can change it here:
- Tools/Customize/Keyboard
- Edit.NextBookmarkInDocument / Edit.PreviousBookmarkIn Document
- Use new shortcut in: Text Editor

Use the keys you want (e.g. F2 / Shift-F2).

Greetings
Peter
GeneralRe: Bookmarks
Andrew Phillips
21:48 16 May '07  
You can actually cycle through bookmarks by:

1. just in the current file
2. all bookmarks in a folder (you can organise your bookmarks into folders which is nice)
3. all bookmarks in the project

Go into the customise dialog and look under the Edit category (Boomark Next/Previous Doc/Folder/). You can put these on a toolbar or assign keyboard shortcuts.


The bookmarks are much better than in VS2003 and even better than VS6 and are now actually useful. (I actually suggested many of these improvements to MS, but they never acknowledged this or that they even got my email.)

However, there are still many areas for improvement - see my comments at http://hexedit.com/cgi-bin/ikonboard.cgi?act=ST;f=5;t=31


Andrew Phillips
http://hexedit.com
andrew @ hexedit.com

GeneralDefinition
StrattonN
5:52 20 Apr '06  
What about the definition of an item. I can use the keyboard shortcut menu but what about the old Shift+F2 to go to a definition.
GeneralRe: Definition
NpnDan
5:17 20 Jun '07  
Just highlight the function name and hit F12. That'll take you to the definition...at least in VS2005.

Danny Cook

GeneralLast Position
StrattonN
4:57 20 Apr '06  
Thanks,

I was desperate to find the old Last Position CTRL+SHIFT+F2. Microsoft said "New Implementation - Use bookmarks" that is just silly. Thanks for CTRL+-!

Nigel
QuestionProperties Window: Ctrl+Shift+First letter to move to property name
LuluSailor
12:59 26 Jan '06  
In VB 6.0 you used to be able to hit: Ctrl + SHIFT + First letter of the property name to jump to another property in the properties window.

Has anyone figured out how to make something like this work in VS 2005 IDE?

I do not see a command in IDE that I could use to create this shortcut capability, so I am not sure how to get this done!



GeneralQuick Copy and Smart Paste
viggity
10:51 17 Jan '06  
First off, thanks for compiling this list, it is very helpful

You can do a quick copy of a selection by holding control and draging the selection where you'd like it.

Also, I hope everyone take some time to play with vertical selections (hold alt and drag a selection). This is incredibly useful if you have to do the same thing to multiple variables/properties, because if you copy a vertical selection, it will paste how you would want it to. ex:

do a vertical selection on (then copy it)
b
b
b
b

and paste it in between a and c on the first line
ac
ac
ac
ac

will yield
abc
abc
abc
abc

Also, you can bring up intellisense with just ctrl+space (no shift needed)

vonzi
GeneralEmbeeded VIM in Visual Studio .NET
oriol_rai
1:54 10 Oct '05  
in vim type

:h MSVisualStudio

you can have best things of both sides.Big Grin


GeneralCustom toolbar
Alligator
20:03 8 May '05  
Hi, Thanks a lot for this article!

Well, another question: I usually customized the toolbar by "new" a personal toolbar and drag some icons to it. However, when I want to use VS at other computer, I have to do it again. Frown

Is there any way that I can take my personalized toolbar along with me?


regards,

Chris.
GeneralRe: Custom toolbar
SathishVJ
20:39 8 May '05  
I was just fiddling around to see if this was possible and probably came upon something.   This might not be the best answer and I give you no guarantees - after all, I fiddled around with it only for a coupla minutes.

C:\Documents and Settings\<your user name>\Application Data\Microsoft\VisualStudio\7.1\1033\CmdUI.PRF

seems to be file that seems to hold this information.   Backup your original CmdUI.PRF file on the new machine.   Then replace the file with the CmdUI.prf file from your original development machine.

It would be good if somebody could further confirm this or give a better answer.

~/sathishvj
GeneralRe: Custom toolbar
C#newcomer
10:15 14 Nov '05  
Laugh
I just tested your solution on VS 2005 and unfortuately it did not work. I could see the items but there is no snippet code attached. Did anybody find out the answer yet?

Bo


Last Updated 4 Feb 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010