5 tricks to improve your coding skills in Visual Studio

Visual Studio is a powerful IDE, which we use to develop .NET applications. We know that programmers are always looking for the simplest and fastest way to solve the problem. So why not use some tricks to develop nimbler? In my opinion we should use a keyboard every time we can do it, because it’s simply faster than using a mouse. In this article I want to show you some tricks and shortkeys to improve coding and avoid using a mouse 🙂 

Before we start: I hope you have a full-size keyboard, with Home and End keys.

1. Snippets

First thing you do when you start coding is defining classes. For every class you need to write some boilerplate, maybe a little, but it’s repeating the same code many times. This is why snippets exist. For often repeatable code fragments, like constructors or properties in C# are snippets ctor and prop. After writing a snippet, you accept it by double-pressing Tab key. Look at the example below.

Snippets gif

2. Line moving

Sometimes you write some code, but you realize that line order should be different. So you mark the line you want to move, cut and paste in another place in the code. What if you could do it in one, simple step? Let’s use the Alt+Up/Down shortcut to move the line up or down. This is what it looks like.

Shortcut to move the line up or down

3. Paste JSON as classes

You know what JSON format is and how data in JSON looks. Lowercase keys, colons and commas. This is totally different how you define C# classes. When you have some JSON data and want to define a class for this structure, there is a tool to do it automatically. Visual Studio has an option Paste JSON as Classes

Define a class gif

4. Multiline editing

Sometimes you want to move some data from JSON or JS code to your C# code. Then you have a lot of work to edit code, using a mouse to change lines, etc. But here you can use shortkeys! For multiline editing is Alt+Shift+Down, then Shift for select and Ctrl+Shift+U for uppercase. For moving caret to the next word is Ctrl+Right or End for moving to the end of line. Look at this example. Awesome, right?

Multiline editing

5. Jump to definition

Programming is not only reading and writing in one file. Classes can inherit classes or implement interfaces from other files. To see how one interface looks you can press Ctrl and click with mouse on the interface name. But you don’t need to use a mouse. Let’s use F12 to jump to definition. There is one more nice tool for interface. Lets click Shift+F12 on the interface name to see a window with all interface implementations!

definition Visual Studio

Tip: When you know that interface has only one implementation, you can use Ctrl+F12 to jump to implementation.

Bonus: Task list

Did you know that Visual Studio has a special window where your tasks are saved? To mark your task, simply write a TODO comment in the code. You can enable the Task List window in the View  tab. Look how it works.

 Task list Visual Studio

Summary

After some time of using presented tricks, the shortkeys will be easy for you and your coding will be faster and more enjoyable 🙂 In the next post I’ll show you some tricks to use while testing and debugging code in Visual Studio. See you!



Check out other articles in the technology bites category

Discover tips on how to make better use of technology in projects

Do you have any questions?