DEV Community

Olabamiji Oyetubo
Olabamiji Oyetubo

Posted on

My 4 most used Visual Studio Keyboard shortcuts.

In today's fast-paced IT world, productivity is not just a desirable trait but an essential one for programmers. The ability to deliver high-quality code efficiently and effectively is paramount. As developers, we must constantly evaluate our workflows and methodologies to ensure we are maximizing productivity. One often overlooked aspect of productivity is the use of keyboard shortcuts. These shortcuts are not just convenient; they can significantly enhance our development time. By reducing the need to switch between the keyboard and mouse, keyboard shortcuts allow us to maintain focus and momentum while coding. They also help us avoid repetitive tasks, such as navigating through menus or typing out long commands, which can be time-consuming and error-prone. With the right shortcuts, we can perform common actions with just a few keystrokes, saving valuable time and effort.

Visual Studio has a lot of out-of-the-box keyboard shortcuts that help reduce the time it takes to perform operations. Here are 4 of my most used ones:

Ctrl K + Ctrl f
This is used to quickly format a block of code if it is highlighted or the entire file if nothing is highlighted.

Unformatted code

And after pressing the shortcut...

Formatted Code

Ctrl K + Ctrl C
Good Ol' reliable. This is used to quickly comment out a piece of highlighted code. Using the piece of code from the previous example

Commented Code

Ctrl K + Ctrl U
Of course, if you want to uncomment that code you just commented, you can use this. Don't forget to highlight.

Ctrl M + Ctrl O
I think this might be my favorite, You can use it to close all functions you have in a file, this can be useful if your file is full of a lot of functions and you need a way to make it more readable so you can better navigate that file.

Here is a file that has 7 functions defined...

File with many functions

After pressing the keyboard shortcut

Functions closed to enable readability

You can find the entire list of Keyboard shortcuts for Visual Studio here. They are all customizable, so you can change what a particular keyboard shortcut does on your Visual Studio instance, or create new ones to suit your particular needs.

If you use Visual Studio often, what are your most used keyboard shortcuts?

Top comments (6)

Collapse
 
mteheran profile image
Miguel Teheran

Thanks for sharing. I want to create a YouTube video with all the common shortcuts in Visual Studio and Visual Studio Code

Collapse
 
bigboybamo profile image
Olabamiji Oyetubo

Go for it!

Collapse
 
marks profile image
Mark Stasak • Edited

Good ones, I also like Ctrl+Shift+F (find in files) and Ctrl+R+R (rename).
I wish they had an easy one to toggle a particular outlining point at (or above) the cursor.

Collapse
 
bigboybamo profile image
Olabamiji Oyetubo

Ah yes. Ctrl + Shift + F is a handy one as well.

Collapse
 
pedrosmasson profile image
Pedro Masson

What about CTRL + SSSSSSSSSSSSSSSSSS buddy?

Collapse
 
bigboybamo profile image
Olabamiji Oyetubo

Ah yes, that too :D