Visual Studio tips wanted.
October 18, 2007 8:08 PM Subscribe
Give me your best Visual Studio tips.
I'm an ASP.NET programmer. I know how to do all the stuff I need in Visual Studio 2005. However, in my ongoing quest for workflow optimization I'd like to get your best nuggets of VS wisdom. Have you done something clever to make your programming life easier, cut down on repetitive tasks etc? Let me know!
Just to be clear, I'm not looking for any programming language specific tips, just stuff for the IDE. VS2008 tips are appeciated as well, since I'll probably be transitioning to that sometime in the future.
I'm an ASP.NET programmer. I know how to do all the stuff I need in Visual Studio 2005. However, in my ongoing quest for workflow optimization I'd like to get your best nuggets of VS wisdom. Have you done something clever to make your programming life easier, cut down on repetitive tasks etc? Let me know!
Just to be clear, I'm not looking for any programming language specific tips, just stuff for the IDE. VS2008 tips are appeciated as well, since I'll probably be transitioning to that sometime in the future.
Best answer: Get Resharper from JetBrains.
if you don't already, get into Test Driven Development (NUnit)
Learn the keyboard shortcuts
Read MSDN Magazine
Learn, and use design patterns.
posted by blue_beetle at 8:53 PM on October 18, 2007 [1 favorite]
if you don't already, get into Test Driven Development (NUnit)
Learn the keyboard shortcuts
Read MSDN Magazine
Learn, and use design patterns.
posted by blue_beetle at 8:53 PM on October 18, 2007 [1 favorite]
Everything slaughters VSS but that is another story.
I would look into learning msbuild and use that as a way to automate any of the repetitive tasks you find in your projects. Also familiarize yourself with using the pre and post build hooks for running scripts (for example to install an assembly in to the GAC or to restart a service).
posted by mmascolino at 8:53 PM on October 18, 2007
I would look into learning msbuild and use that as a way to automate any of the repetitive tasks you find in your projects. Also familiarize yourself with using the pre and post build hooks for running scripts (for example to install an assembly in to the GAC or to restart a service).
posted by mmascolino at 8:53 PM on October 18, 2007
Oh, it's not really a workflow thing, but I found it super, super nice to have two Windows VMWare images I could start up and test deployments to - one deployed to a 'fresh' install of Windows/IIS/.NET, that would be restored after every deploy, and one that mirrored the actual deployment environment as closely as possible. That saved many, many headaches. Note that this was also with 2003; we expressly didn't upgrade to 2005, because it broke every last detail of our deployment processes and made life generally miserable.
posted by devilsbrigade at 10:00 PM on October 18, 2007
posted by devilsbrigade at 10:00 PM on October 18, 2007
Best answer: Some of these might be C/C++ specific, and some of the key bindings might not be the default, but you should be able to find them in the key binding dialogue by their description.
F12 with the cursor over a function or variable name jumps to the definition of the function or declaration of the variable.
Ctrl+Shift+F find in all files in the project. So damn useful.
Ctrl+- and Ctrl+shift+- jump back and forth between code locations. For example if you jump to a file and can't remember the last one you were in, or accidently hit end, then hit ctrl+- to take you back to the last cursor location.
Ctrl+shift+v (called cycle clipboard ring I think, this probably isn't the default binding). Lets you cycle through things you've copied on to the clipboard.
Ctrl+shift+R lets you record a macro. So hit the keys then do whatever manipulation you want to repeat (hint: you can do just about anything you could normally do in the editor). Hit Ctrl+shift+r again to end recording the macro, then hit Ctrl+Shift+P to play the macro back. There's a slight learning curve to this, but it can often reduce complex tasks down to holding Ctrl+Shift+P for a minute or two.
Ctrl+k then ctrl+k sets a bookmark. Hit Ctrl+K then Ctrl+n to cycle between bookmarks.
Ctrl+] jumps from a closing bracket to the opening bracket, brace, or paren and vice-versa.
Alt+F8 automatically spaces the line to the correct tab depending on brackets and whatnot. Useful if you take something out of a loop(you can do it while selecting multiple lines at once just like you can with tab), or if some idiot gave you a file that has incorrect spacing or mixed spaces/tabs.
Ctrl+Shift+Space brings up the intellisense window. Can save a few seconds waiting for it to popup.
If the intellisense data gets screwed up then delete your projects .ncb file and restart visual studio.
Get VSFileFinder and bind opening it to a key(I use Alt+F1). Then you can quickly hit a key type in the name of a file to open it instead of searching through the solution tab.
Debugging
If you have a pointer that you want to view as an array type in "Arrayname,NumOfElements" to the watch window (NumOfElements can be a literal or a variable name), to see all the elements in a nice list.
Breakpoint conditions (not really visual studio specific, but still damn useful and underused), right click on a breakpoint and choose properties, under condition you can choose to stop when the expression you enter is true, or after a certain number of times or only after another breakpoint has been hit, etc. It seems whenever I sit down at someone elses desk to debug they either don't know that this exists or they don't use it nearly as much as they should (or at least as much as I do!).
You can also customize how the debugger shows your own custom types in the debugger by messing with autoexp.dat. This allows you to customize the short and long descriptions for variables shown. I think there is also a way to write code driven visualization stuff if you use managed code, but I don't so I'm not 100% sure.
Can't think of anything else off the top of my head, but I'll post more if I get inspired at work tomorrow.
posted by hamhed at 10:55 PM on October 18, 2007 [3 favorites]
F12 with the cursor over a function or variable name jumps to the definition of the function or declaration of the variable.
Ctrl+Shift+F find in all files in the project. So damn useful.
Ctrl+- and Ctrl+shift+- jump back and forth between code locations. For example if you jump to a file and can't remember the last one you were in, or accidently hit end, then hit ctrl+- to take you back to the last cursor location.
Ctrl+shift+v (called cycle clipboard ring I think, this probably isn't the default binding). Lets you cycle through things you've copied on to the clipboard.
Ctrl+shift+R lets you record a macro. So hit the keys then do whatever manipulation you want to repeat (hint: you can do just about anything you could normally do in the editor). Hit Ctrl+shift+r again to end recording the macro, then hit Ctrl+Shift+P to play the macro back. There's a slight learning curve to this, but it can often reduce complex tasks down to holding Ctrl+Shift+P for a minute or two.
Ctrl+k then ctrl+k sets a bookmark. Hit Ctrl+K then Ctrl+n to cycle between bookmarks.
Ctrl+] jumps from a closing bracket to the opening bracket, brace, or paren and vice-versa.
Alt+F8 automatically spaces the line to the correct tab depending on brackets and whatnot. Useful if you take something out of a loop(you can do it while selecting multiple lines at once just like you can with tab), or if some idiot gave you a file that has incorrect spacing or mixed spaces/tabs.
Ctrl+Shift+Space brings up the intellisense window. Can save a few seconds waiting for it to popup.
If the intellisense data gets screwed up then delete your projects .ncb file and restart visual studio.
Get VSFileFinder and bind opening it to a key(I use Alt+F1). Then you can quickly hit a key type in the name of a file to open it instead of searching through the solution tab.
Debugging
If you have a pointer that you want to view as an array type in "Arrayname,NumOfElements" to the watch window (NumOfElements can be a literal or a variable name), to see all the elements in a nice list.
Breakpoint conditions (not really visual studio specific, but still damn useful and underused), right click on a breakpoint and choose properties, under condition you can choose to stop when the expression you enter is true, or after a certain number of times or only after another breakpoint has been hit, etc. It seems whenever I sit down at someone elses desk to debug they either don't know that this exists or they don't use it nearly as much as they should (or at least as much as I do!).
You can also customize how the debugger shows your own custom types in the debugger by messing with autoexp.dat. This allows you to customize the short and long descriptions for variables shown. I think there is also a way to write code driven visualization stuff if you use managed code, but I don't so I'm not 100% sure.
Can't think of anything else off the top of my head, but I'll post more if I get inspired at work tomorrow.
posted by hamhed at 10:55 PM on October 18, 2007 [3 favorites]
MS blogger Sara Ford posts a daily Visual Studio tip:
http://blogs.msdn.com/saraford/default.aspx
posted by rdhatt at 12:31 AM on October 19, 2007
http://blogs.msdn.com/saraford/default.aspx
posted by rdhatt at 12:31 AM on October 19, 2007
now that i have had some coffee. there are two built in features i use everyday that a surprisingly large number of developers seem to be unaware of.
as hamhed said Ctrl+Shift+F find in all files in the project is quite useful.
in addition to that i would suggest using the immediate window if you do not already.
posted by phil at 6:38 AM on October 19, 2007
as hamhed said Ctrl+Shift+F find in all files in the project is quite useful.
in addition to that i would suggest using the immediate window if you do not already.
posted by phil at 6:38 AM on October 19, 2007
Best answer: +buy resharper
Check out Test Driven.Net for excellent nUnit integration within VS.
Also, read Charles Petzold's article on VS and mind root. Try not to succumb to the perils he mentions, and enjoy the benefits of a pretty decent IDE.
posted by whycurious at 8:29 AM on October 19, 2007
Check out Test Driven.Net for excellent nUnit integration within VS.
Also, read Charles Petzold's article on VS and mind root. Try not to succumb to the perils he mentions, and enjoy the benefits of a pretty decent IDE.
posted by whycurious at 8:29 AM on October 19, 2007
I use SlickEdit, mainly to display a highlighted ruler in the current line where the focus is set.
posted by WizKid at 10:24 AM on October 19, 2007
posted by WizKid at 10:24 AM on October 19, 2007
« Older Can you recommend a camera for macro photography? | NYC, Halloween, easy ideas for costumes Newer »
This thread is closed to new comments.
posted by devilsbrigade at 8:32 PM on October 18, 2007