Practical Visual Studio Tips Part 1

One of the best ways to become a solid, more productive and effective developer is to really master the things you do most often.

The kickoff article that initiated this practical Visual Studio tips series highlighted the extract method refactoring (my absolute favorite) and how we can harness Visual Studio’s keyboard shortcuts like a Dothraki warrior so that we can write code fast (if we want to), while improving readability.

For this next part in the series, we’ll take a look at two more shortcuts that you can use on a daily basis to speed up your workflow. Now, these particular shortcuts are rather basic, obvious even, but by giving them focus here and practicing them, you’ll use them more consistently and integrate them into a daily habit.

We humans are funny, or at least I am, anyway.

I’ll do the same thing over and over, and even after learning a faster way to do it, I’ll continue doing it my old way anyway simply because that’s the groove currently patterned in my brain.

The purpose of this article and often many of my articles are to give old patterns a second look so we can question our behaviors and change if necessary.

Tab + arrow key suggestion invocations

For the first one, we’ll go reaaaal primitive, but I’ll add a twist, so stick with me.

When you’re writing code in Visual Studio, a program called Intellisense is actively analyzing each character you type and trying to determine what you might be trying to write.

Typing is slow, so if the editor can predict what you are about to write with accuracy, you can lean on it to reduce the number of keystrokes you have to make.

It’s here to make our lives easier!

On top of that I’ve found that Intellisense is pretty damn smart, and either suggests exactly what I want right away, or the option I want is one or two list items up or down.

Pay particular attention below at how I can type these extra long statements in about half the number of keystrokes compared to typing each letter manually.

What I want for you is to get used to either hitting the tab key to invoke the suggestion, or using the arrow keys on your keyboard to select the desired option in the Intellisense dropdown menu, then hitting tab or enter to invoke it.

Type only the first few characters and let your eyes pinpoint the correct suggestion as it appears.

Start to relax and trust that what you want will be available and lean on Intellisense to improve your productivity and make you seem like a developer wizard to your friends and teammates.

Funny side note, I’ve actually had two past lovers comment “Damn, that’s really hot” when I’m dishing out commands to the console.

Who would have thought, skill and proficiency is sexy!

Master your editor and keyboard.

Renaming like a savage

Alright, now you’re going about your day, shrinking big methods via extract method, leaning on Intellisense predictions so you can type less, what else can we do to pro it up?

Another very common thing you probably do as a compassionate and considerate dev, is constantly refine your names.

The longer you work on a codebase, the better your understanding of it, which leads to clearer, more accurate class, method, property, and variable names.

I rename all the time. Often I’ll come up with one name at the start of a method, then after actually implementing the method, I’ll realize it could be named in a way that conveys it’s intent even better.

For that reason, making the process of renaming as fast as possible is another worthy endeavor.

Fortunately for us, it has a built-in keyboard shortcut, so we only have to understand how to use it, and to remember it.

The first act in a renaming is to select the entire existing name you’d like to change.

To do that, the best way I’ve found is to use your mouse or trackpad and double-click the word itself.

Visual Studio understands logical delimiters of a name in code and will automatically highlight the word.

Once highlighted, hold down the CTRL key, then quickly hit the letter R twice.

Once the rename refactoring is invoked, you can begin typing your new name at once and notice it changing across all usages.

And there you have it.

Get used to trusting intellisense, and speed up your renames.

In the next article in the series, we’ll either continue mastering common tasks, or I may go for something new that peaks my interest… I haven’t quiiiite decided.

Stay tuned!