6 Visual Studio Tips to Increase Your Productivity | Mosh

Programming with Mosh · Intermediate ·🏗️ Systems Design & Architecture ·11y ago

Key Takeaways

The video demonstrates various productivity tips and tools in Visual Studio, including bookmarks, code snippets, and Resharper, to improve coding efficiency and systems design.

Full Transcript

bookmarks is one of the greatest features of Visual Studio that is unfortunately hardly ever used basically you put bookmarks in various parts of the code to remind you that you need to get back there and do something this is often very useful when you're focusing on a task but you see a problem somewhere else in the code you don't want to get distracted from the or original task at hand so you just leave a bookmark there and get back to your original task later you can look at all your bookmarks and get back to do whatever you wanted to do let's see this in action imagine you're in the middle of a task and you spot something here in method one you don't want to get distracted so you leave a bookmark here by pressing contrl and K twice note this little icon here this represents a bookmark to see all your bookmarks press contrl and W as in shorted for window and then b as in short for bookmark note that the bookmark I just created is listed here you can double click it and change its name to something more meaningful like requires refactoring I know what you're thinking you're probably saying Marsh didn't you advise me not to use the mouse while programming yes I did say say that to be honest with you at the time of recording this video I don't know a way to rename a bookmark without using the mouse hopefully one day when I figure it out I will update this video and teach you and everyone else how to do it note that you can remove a bookmark by selecting it here and then clicking the delete icon here but you can also remove it in the code position the cursor on the line where you have a bookmark and then press contrl K twice code Snippets are one of the coolest features of Visual Studio that can speed up your coding a lot let's see this in action here I've got a class called Coast me put examples let's say we want to create a Constructor for this class most developers do it this way here is a f faster way of doing that using a code snippet did you see how faster it is so how does this work there are certain reserved keywords that you can use to automatically insert a readymade code snippet into your code in this case I use the keyword c tour as in shorted for Constructor and then press the tab let's try again I didn't have to manually type the name of a class for the Constructor Method All I typed was c tour it's very easy now let's create an auto implemented property here called first name this is how developers who don't use code Snippets do this you can do this faster using a code snippet just type prop and then press the tab note that the type is highlighted it's ready for you to specify the data type of this property we type in string and then press the tab again now the focus is on the name of the property let's give it a name as you see some code Snippets require parameters in this case the name and type of a property are the parameters that we have to manually specify with the last example for a Constructor we don't have to specify any parameters when you need to specify parameters you hit the tab to move to the next parameter here is another code snippet if you need to create a property with full get and set methods you type in prop full note that Visual Studio created a private field and a public property here here is another example let's say we want to type console the right line in the Constructor here we can do so by typing CW as in shorted for console. right line and then press the tab there you go isn't that great here is another one let's say in this class we would like to implement the equals method we can do this by typing equals and pressing the tab there you go Visual Studio created two methods for us equals and get hash code you can go ahead and customize these methods according to your needs here is another useful one to create a try catch block use try like this or you can use trf if you want to create a tri finally block another useful code snippet is four let's try it or we can use 4 R for a four Loop that decrements the loop variable after each iteration here is another useful one let's create a list of strings and call it names let's say we want to iterate over this list using a 4 each block so we type in for each and press tab because I created the 4 each Block near the names variable Visual Studio detected that I may want to iterate over this collection so I don't have to manually specify the name of the collection or The Loop variable just press tab to the code snippet you can also use while or do code Snippets for Loops let's try it here I've got a piece of code that is not properly formatted as you see we can go ahead and clean it up a little like this so we select these few lines here and then press the Tab Key to move them one tap stop to the right or we can press shift and tab to move them one tap stop to the left there is also a faster and better way to clean up this code you can select everything here using control and a and then press contrl K and then crl f it Auto automatically formats the entire selection it's a very useful shortcut to know and I use it all the time but let me show you even a faster and easier way to clean up your code let me revert back the code to its original dirty State first note these few name spaces here as you see they're not used that's why they're grade out also the code is not formatted properly I can fix all of these issues with only one shortcut contrl and S which is for saving the file see what happened all those unused name spaces are removed and my code is perfectly formatted so how did this happen this is because I've installed an extension to visual studio that is called productivity power tools to get productivity power tools open up your browser and search for productivity Power Tools in Google you'll find this page on Visual Studio Gallery click the download button here this will download a VSS file which is basically an extension to visual studio just double click it and it will install automatically it's very easy you may have to restart Visual Studio after installation once you got the productivity power tools then go to tools and then options here select productivity power tools and then power commands General note these two checkboxes here format document unsave and remove and sort usings on Save By enabling these options your code is automatically cleaned up every time you save it I think they're enabled by default anyway but it's worth double-checking here I've got a few tabs open as you see program.cs is the active tab let's say we want to open sample. CS tab I've seen a lot of developers use the mouse to change tabs here but again as a programmer you should rely on your keyboard the less you switch between the keyboard in the mouse the faster you'll be at coding so how can we switch to sample that CS tab here with without touching the mouse just press control and tab to cycle through the open Windows like this or you can press control shift and tab to go backward here is another way to do this you can press control and F6 to go to the next tab or control shift and F6 to go to the previous tab isn't that great it's much easier and faster than using the mouse now let's look at some ways to close tabs if you want to close the current tab press contrl and F4 it's gone see let me share another technique with you that's going to increase your productivity significantly when I work I always focus on only one task at a time each task is a small piece of work that I can and finish within 40 minutes or less that usually requires very few files or tabs to have open in Visual Studio there are a couple of great benefits to this first it helps you get focus by reducing distractions you should only have the files open that you really need to work on the second benefit is that it makes it easier to switch between tabs imagine if you had 10 or more tabs open here every time you press control and tab you see lots of items to cycle through this wastes a lot of time and energy so I highly recommend you to have only very few tabs open that you really need after you finish each task clean up your workspace by closing all the open tabs the fast way to do this is to press alt W and L now you may ask how can I open files for my next task without going to solution Explorer the answer is to press control and coma this brings up up the navigate dialogue which is extremely helpful with this dialogue you can type the name of a file a class or even a method and quickly open that in Visual Studio there's no need to grab the mouse and open the file VI solution Explorer let me type method 2 here as you see it shows all the places where I have a method by the name of method 2 now we can hit the Tab Key to move for Focus to the results and then use up and down arrows to select an item then we press enter and there you go Visual Studio open the file and even put the cursor right at the beginning of the method let's open the navigate dialogue again so I press control and coma but this time I type program as you see we have two items in the results the first one represents the class while the second one represents the actual file isn't that great imagine how much time you would waste if you had to use the mouse to expand and collapse folders in the solution Explorer to find a file especially the larger your project the harder it gets to find a file in solution Explorer as you saw if you know the name of a file it's much faster to look it up here so next time you switch to Mouse to open a file via solution Explorer or close a tab remember that you can do the same with keyboard and and save yourself lots of time and here's one more trick for this lecture you're going to love this press shift alt and enter this takes you to the full screen view of the current tab it's much easier to focus on this tab without any distractions to exit the full screen view just use the same shortcut shift alt and enter sometimes times when you are dealing with long blocks of code it's better to collapse the blocks you're not interested in so you can focus on a small part of the code take a look at this code let's say we want to work on method one as you see method 2 is a long method and is distracting we can put our cursor anywhere in the method or on the Declaration line and press contrl and M twice see what happened it's much easier to focus on method one now later if you want to expand method to you can use the same shortcut to expand it like this note that you can apply this shortcut at any level for example we can put the cursor here near the Declaration of the class and collapse the entire class or even the name space let's say in this class we would like to create create a private field of type code inspector and initialize it from The Constructor typically this is how most developers write this code without using resharper okay now let's see the resharper way so we just declare the private field first okay now note this blue underline here whenever resharper sees something in your code that can be improved it underlines it like that if you put the cursor here where the underline is we also get this icon on the left side a yellow bulb is like a warning in this case because we declared this private field but never used it or initialized it resharper is wondering why we need this in the first place maybe something is missing so so at this point we can activate resharper commands using alt and enter this is what I call a golden shortcut you're going to see me using this shortcut over and over and over all right so now let's take a look at what we can do with this resharper is suggesting three things we can do to improve this code we can initialize it from The Constructor we can remove it because it's not used anywhere or we can comment it out in this case we want to initialize this from The Constructor so let's select the first item there you go so our private field is initialized from the construct this is much faster than manually writing this code we could also write this code by starting from the Constructor first and then having resharper create and initialize a private field for us let me show you how it works first we create a Constructor using the seor code snippet remember this I told you this in the code snippet's lecture okay now we Define an argument for this Constructor we just type CI as in short for code inspector this is the camel humps that I told you earlier then control and space for resharper to suggest the name and now alt and enter to activate the refactoring commands and select the first one when you do this a few times you're going to get really fast at it and you will do it without even thinking about it let me show you how I do this for

Original Description

Get the COMPLETE COURSE: http://bit.ly/2IEk6Lo My blog http://www.programmingwithmosh.com/ Facebook https://www.facebook.com/programmingw... Twitter https://twitter.com/moshhamedani
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Programming with Mosh · Programming with Mosh · 1 of 60

← Previous Next →
6 Visual Studio Tips to Increase Your Productivity | Mosh
6 Visual Studio Tips to Increase Your Productivity | Mosh
Programming with Mosh
2 Visual Studio Keyboard Shortcuts that Speed Up Debugging Applications | Mosh
Visual Studio Keyboard Shortcuts that Speed Up Debugging Applications | Mosh
Programming with Mosh
3 Backbone.js Tutorial Part 2 - Backbone.js Models: Working with Model Attributes
Backbone.js Tutorial Part 2 - Backbone.js Models: Working with Model Attributes
Programming with Mosh
4 Backbone.js Tutorial Part 3 - Backbone.js Models: Model Validation
Backbone.js Tutorial Part 3 - Backbone.js Models: Model Validation
Programming with Mosh
5 Backbone.js Tutorial Part 4 - Backbone.js Models: Model Inheritance
Backbone.js Tutorial Part 4 - Backbone.js Models: Model Inheritance
Programming with Mosh
6 Backbone.js Tutorial Part 1 - Backbone.js Models: Creating Models
Backbone.js Tutorial Part 1 - Backbone.js Models: Creating Models
Programming with Mosh
7 Backbone.js Tutorial Part 5 - Backbone.js Models: Syncing Models with the Server
Backbone.js Tutorial Part 5 - Backbone.js Models: Syncing Models with the Server
Programming with Mosh
8 Backbone.js Tutorial Part 6 - Backbone.js Collections: Creating Collections
Backbone.js Tutorial Part 6 - Backbone.js Collections: Creating Collections
Programming with Mosh
9 Backbone.js Tutorial Part 7 - Backbone.js Collections: Working with Collections
Backbone.js Tutorial Part 7 - Backbone.js Collections: Working with Collections
Programming with Mosh
10 Backbone.js Tutorial Part 8 - Backbone.js Collections: Fetching Collections from the Server
Backbone.js Tutorial Part 8 - Backbone.js Collections: Fetching Collections from the Server
Programming with Mosh
11 Backbone.js Tutorial Part 9 - Backbone.js Views: Creating Views
Backbone.js Tutorial Part 9 - Backbone.js Views: Creating Views
Programming with Mosh
12 Backbone.js Tutorial Part 10 - Backbone.js Views: Passing Data to Views
Backbone.js Tutorial Part 10 - Backbone.js Views: Passing Data to Views
Programming with Mosh
13 Backbone.js Tutorial Part 11 - Backbone.js Views: Handling the DOM Events
Backbone.js Tutorial Part 11 - Backbone.js Views: Handling the DOM Events
Programming with Mosh
14 Backbone.js Tutorial Part 12 - Backbone.js Views: Handling the Model Events
Backbone.js Tutorial Part 12 - Backbone.js Views: Handling the Model Events
Programming with Mosh
15 Backbone.js Tutorial Part 13 - Backbone.js Views: Handling Collection Events
Backbone.js Tutorial Part 13 - Backbone.js Views: Handling Collection Events
Programming with Mosh
16 Backbone.js Tutorial Part 14 - Backbone.js Views: Templating
Backbone.js Tutorial Part 14 - Backbone.js Views: Templating
Programming with Mosh
17 Clean Code: Learn to write clean, maintainable and robust code
Clean Code: Learn to write clean, maintainable and robust code
Programming with Mosh
18 C# Events and Delegates Made Simple | Mosh
C# Events and Delegates Made Simple | Mosh
Programming with Mosh
19 C# Generics Tutorial: Whats and Whys | Mosh
C# Generics Tutorial: Whats and Whys | Mosh
Programming with Mosh
20 Debugging C# Code in Visual Studio | Mosh
Debugging C# Code in Visual Studio | Mosh
Programming with Mosh
21 Repository Pattern with C# and Entity Framework, Done Right | Mosh
Repository Pattern with C# and Entity Framework, Done Right | Mosh
Programming with Mosh
22 Angular 2 Tutorial for Beginners: Learn Angular 2 from Scratch | Mosh
Angular 2 Tutorial for Beginners: Learn Angular 2 from Scratch | Mosh
Programming with Mosh
23 Architecture of Angular 2+ Apps
Architecture of Angular 2+ Apps
Programming with Mosh
24 Working with Components in Angular
Working with Components in Angular
Programming with Mosh
25 C# Tutorial For Beginners - Learn C# Basics in 1 Hour
C# Tutorial For Beginners - Learn C# Basics in 1 Hour
Programming with Mosh
26 Difference between Junior and Senior Developers
Difference between Junior and Senior Developers
Programming with Mosh
27 Step-by-step ASP.NET MVC Tutorial for Beginners | Mosh
Step-by-step ASP.NET MVC Tutorial for Beginners | Mosh
Programming with Mosh
28 [Pluralsight]: Become a Full-stack .NET Developer
[Pluralsight]: Become a Full-stack .NET Developer
Programming with Mosh
29 Xamarin Forms Tutorial: Build Native Mobile Apps with C#
Xamarin Forms Tutorial: Build Native Mobile Apps with C#
Programming with Mosh
30 Value Types and Reference Types in JavaScript
Value Types and Reference Types in JavaScript
Programming with Mosh
31 Using Redux in Angular 2+ Apps | Mosh
Using Redux in Angular 2+ Apps | Mosh
Programming with Mosh
32 Testing Angular 2+ Apps with Jasmine and Karma | Mosh
Testing Angular 2+ Apps with Jasmine and Karma | Mosh
Programming with Mosh
33 Profile and optimize your Angular 2 apps
Profile and optimize your Angular 2 apps
Programming with Mosh
34 Build a Real-world App with ASP.NET Core and Angular 2
Build a Real-world App with ASP.NET Core and Angular 2
Programming with Mosh
35 Entity Framework 6 Tutorial: Learn Entity Framework 6 from Scratch
Entity Framework 6 Tutorial: Learn Entity Framework 6 from Scratch
Programming with Mosh
36 Two-way Binding and ngModel in Angular 4
Two-way Binding and ngModel in Angular 4
Programming with Mosh
37 Udemy Live 2017: Teaching Tech Panel
Udemy Live 2017: Teaching Tech Panel
Programming with Mosh
38 Demo of An E-commerce App Built with Angular, Firebase and Bootstrap 4
Demo of An E-commerce App Built with Angular, Firebase and Bootstrap 4
Programming with Mosh
39 My Brand New Angular Course
My Brand New Angular Course
Programming with Mosh
40 TypeScript Tutorial - TypeScript for React - Learn TypeScript
TypeScript Tutorial - TypeScript for React - Learn TypeScript
Programming with Mosh
41 Access Modifiers in TypeScript
Access Modifiers in TypeScript
Programming with Mosh
42 TypeScript Interfaces
TypeScript Interfaces
Programming with Mosh
43 TypeScript Classes
TypeScript Classes
Programming with Mosh
44 TypeScript Constructors
TypeScript Constructors
Programming with Mosh
45 TypeScript Properties
TypeScript Properties
Programming with Mosh
46 Angular Tutorial for Beginners: Learn Angular & TypeScript
Angular Tutorial for Beginners: Learn Angular & TypeScript
Programming with Mosh
47 AngularJS vs Angular 2 vs Angular 4 | Mosh
AngularJS vs Angular 2 vs Angular 4 | Mosh
Programming with Mosh
48 Angular Material Tutorial | Mosh
Angular Material Tutorial | Mosh
Programming with Mosh
49 Angular Animations Tutorial | Mosh
Angular Animations Tutorial | Mosh
Programming with Mosh
50 Firebase in Angular Applications | Mosh
Firebase in Angular Applications | Mosh
Programming with Mosh
51 Deploying Angular Applications | Mosh
Deploying Angular Applications | Mosh
Programming with Mosh
52 Building Forms in Angular Apps | Mosh
Building Forms in Angular Apps | Mosh
Programming with Mosh
53 Directives in Angular Applications
Directives in Angular Applications
Programming with Mosh
54 Routing and Navigation in Angular | Mosh
Routing and Navigation in Angular | Mosh
Programming with Mosh
55 Angular 4 in 40 Minutes
Angular 4 in 40 Minutes
Programming with Mosh
56 [NEW COURSE] Unit Testing for C# Developers
[NEW COURSE] Unit Testing for C# Developers
Programming with Mosh
57 Unit Testing C# Code - Tutorial for Beginners
Unit Testing C# Code - Tutorial for Beginners
Programming with Mosh
58 C# Classes Tutorial | Mosh
C# Classes Tutorial | Mosh
Programming with Mosh
59 C# Object Initializers Tutorial
C# Object Initializers Tutorial
Programming with Mosh
60 C# Constructors Tutorial | Mosh
C# Constructors Tutorial | Mosh
Programming with Mosh

This video teaches viewers how to increase their productivity in Visual Studio by utilizing features such as bookmarks, code snippets, and Resharper. By following the tips and tools demonstrated, viewers can improve their coding efficiency and systems design skills.

Key Takeaways
  1. Press Ctrl+K twice to create a bookmark
  2. Use code snippets to speed up coding
  3. Activate Resharper commands using alt and enter
  4. Select first item to initialize private field from Constructor
  5. Create a Constructor using code snippet
  6. Define an argument for Constructor
  7. Type CI for code inspector
💡 Using Resharper and code snippets can significantly improve coding efficiency and systems design in Visual Studio

Related Reads

📰
ArborDb: a Rust document store where reading one field doesn't get slower as the record grows
Learn about ArborDb, a fast Rust document store that maintains read performance regardless of record size
Dev.to · Frédéric Meyer
📰
The 2026 World Cup: A Stress Test For Enterprise Intelligence
The 2026 World Cup will stress test enterprise intelligence, requiring organizations to operate efficiently across massive networks
Forbes Innovation
📰
Why Interoperability Can Be A Tough Sell In Manufacturing
Interoperability can be challenging to implement in manufacturing due to various reasons, making it a tough sell for manufacturers
Forbes Innovation
📰
Introduction: What are Design Patterns and Why Should You Care?
Learn about design patterns and their importance in software development to improve coding efficiency and effectiveness
Dev.to · Manoj Khatri
Up next
What is API and How it Works? | API Explained for Beginners | Tamil | Karthik's Show
Karthik's Show
Watch →