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.
- Create/Remove Bookmark -
Ctrl+K, Ctrl+K
- Move to next bookmark -
Ctrl+K, Ctrl+N
- Move to previous bookmark -
Ctrl+K, Ctrl+P
- Clear all bookmarks -
Ctrl+K, Ctrl+L
21. Code Formatting
- Auto-format selection -
Ctrl+K, Ctrl+F
- Convert to lower case -
Ctrl+U
- Convert to upper case -
Ctrl+Shift+U
- Comment selection -
Ctrl+K, Ctrl+C
- Uncomment selection -
Ctrl+K, Ctrl+U
22. Outlining
I like this feature that allows me to hide code that is irrelevant to what I'm currently working on.
- Fold/Unfold the current code block -
Ctrl+M, Ctrl+M
- Unfold all -
Ctrl+M, Ctrl+L
- Stop outlining -
Ctrl+M, Ctrl+P
- Fold all -
Ctrl+M, Ctrl+O
23. Build and Debug
- Build -
Ctrl+Shift+B
- Run -
Ctrl+F5
- Debug -
F5
- Cycle through build errors -
F8
| You must Sign In to use this message board. |
|
|
 |
|
|
 |
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
 | Rename  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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
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!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Just highlight the function name and hit F12. That'll take you to the definition...at least in VS2005.
Danny Cook
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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!
|
| Sign In·View Thread·PermaLink | 1.50/5 |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
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.
Is there any way that I can take my personalized toolbar along with me?
regards,
Chris.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
 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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|