Writing Faster Code – I’m sure that many of you already know the following tips. Some of these are probably not even confined to Visual Studio 2013. Nevertheless, I called the article ‘Writing Faster Code With Visual Studio 2013’ because that is the version of the Visual Studio IDE I use. I feel however that this is a nice article to include on my blog, as it will make many of us more productive.
Writing Faster Code
So what are these tips? They are really simple. How many characters does it take to get to the ‘WriteLine’ method of the Console class? If you’re doing this often, you will no doubt be using copy and paste.
Here is an easier method. Instead of writing out the code fully (letting intellisense filter it as you type), use Pascal Case instead. Intellisense automatically recognizes this and filters the results accordingly. (By the way, this is PascalCase while this is camelCase.)
The same trick can be use to write something like StringBuilder.
When writing code and you want to create methods, you can simply use the Ctrl+K+M shortcut. You will see that I have added a call to a non-existent method called ‘GetHashedData’. Visual Studio 2013 quite rightly underlines the error.
Highlight the underlined GetHashedData method call and press Ctrl+K+M. Visual Studio 2013 reciprocates immediately.
When you want to navigate to the definition of a method or variable, put your cursor on the method or variable and press F12 on the keyboard. You will be taken to the referenced method or variable in the wink of an eye.
If you just want to take a peek at the method instead of actually navigating to the method itself, you can use Peek Definition. To do this, press Alt+F12. To close the preview press Esc.
Quickly surround your code by pressing Ctrl+K+S. I find this useful for surrounding my code with regions.
Sometimes having to sift through multiple lines of code and to navigate up and down the code file, can become tedious. Quickly collapse highlighted sections of code by pressing Ctrl+M+H. To expand the collapsed region again, press Ctrl_M+U or just click on the + in the editor.
These are but a few shortcuts and tricks I use to make my coding faster. There are numerous other shortcuts out there. Throw in a few 3rd party extensions (Think PowerTools) and you can really fly through mundane, repetitive coding tasks in no time. If you have a tip to share, do so in the comments!