What are everyones best tips for using VS2010 to develop rapidly in .NET? So as not to make this too broad, I’m looking for things like:
- Use the ‘Ctrl K + D’ shortcut combination to automatically format the current code page
- Select multiple lines of code and use ‘Ctrl K + C’ to comment them all out at once
- Create ‘code snippets’ to allow quick insertion of custom code and use “Ctrl K + Ctrl X” to quickly access them in the code editor
I’m not asking for example about tools for automatic code generation or best practices being used (e.g. using a business and data layer), rather specifically about the quick ‘tips’ that we can use throughout everyday development in VS2010 to make coding quicker.
In case you don’t already know how to locate the VS 2010 short cut key cheat sheet, here it is
These are a few of my most used.
Navigation
My favouriate for navigation and jumping back and forth between code would be Ctrl + ‘-‘ and Ctrl + Shift + ‘-‘. These jump back and forward respectively to different parts of code you have edited or focused on. This works across files as well which helps if you are doing a piece of work that is spread across classes.
Ctrl + ‘,’ is also good for jumping to classes, methods or properties you know the name of. This provides an auto filter page of all your solution.
Ctrl + Tab and Ctrl + Shift + Tab works as expected to alternate between your open code files. These keys work in many windows applications.
Auto complete
A few of my favourite auto complete features are ‘ctor’ and ‘prop’. If you type these within a C# context for example and hit ‘Tab’ twice, ‘ctor’ for example will generate a default constructor and ‘prop’ will stub a property. This also works for things like ‘switch’, ‘for’, ‘foreach’ etc. Just try it out!
For web work, this use of double ‘Tab’ key also works with a lot of html elements. Eg, type ‘div’ and hit ‘Tab’ twice will create a div element. ‘ul’ will create a list with a single ‘li’. Most html elements will generate some valid html for you with just the element name + ‘Tab’ + ‘Tab’.