6 Visual Studio Tips to Increase Your Productivity | Mosh
Skills:
Systems Design Basics80%
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 →
▶
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
6 Visual Studio Tips to Increase Your Productivity | Mosh
Programming with Mosh
Visual Studio Keyboard Shortcuts that Speed Up Debugging Applications | Mosh
Programming with Mosh
Backbone.js Tutorial Part 2 - Backbone.js Models: Working with Model Attributes
Programming with Mosh
Backbone.js Tutorial Part 3 - Backbone.js Models: Model Validation
Programming with Mosh
Backbone.js Tutorial Part 4 - Backbone.js Models: Model Inheritance
Programming with Mosh
Backbone.js Tutorial Part 1 - Backbone.js Models: Creating Models
Programming with Mosh
Backbone.js Tutorial Part 5 - Backbone.js Models: Syncing Models with the Server
Programming with Mosh
Backbone.js Tutorial Part 6 - Backbone.js Collections: Creating Collections
Programming with Mosh
Backbone.js Tutorial Part 7 - Backbone.js Collections: Working with Collections
Programming with Mosh
Backbone.js Tutorial Part 8 - Backbone.js Collections: Fetching Collections from the Server
Programming with Mosh
Backbone.js Tutorial Part 9 - Backbone.js Views: Creating Views
Programming with Mosh
Backbone.js Tutorial Part 10 - Backbone.js Views: Passing Data to Views
Programming with Mosh
Backbone.js Tutorial Part 11 - Backbone.js Views: Handling the DOM Events
Programming with Mosh
Backbone.js Tutorial Part 12 - Backbone.js Views: Handling the Model Events
Programming with Mosh
Backbone.js Tutorial Part 13 - Backbone.js Views: Handling Collection Events
Programming with Mosh
Backbone.js Tutorial Part 14 - Backbone.js Views: Templating
Programming with Mosh
Clean Code: Learn to write clean, maintainable and robust code
Programming with Mosh
C# Events and Delegates Made Simple | Mosh
Programming with Mosh
C# Generics Tutorial: Whats and Whys | Mosh
Programming with Mosh
Debugging C# Code in Visual Studio | Mosh
Programming with Mosh
Repository Pattern with C# and Entity Framework, Done Right | Mosh
Programming with Mosh
Angular 2 Tutorial for Beginners: Learn Angular 2 from Scratch | Mosh
Programming with Mosh
Architecture of Angular 2+ Apps
Programming with Mosh
Working with Components in Angular
Programming with Mosh
C# Tutorial For Beginners - Learn C# Basics in 1 Hour
Programming with Mosh
Difference between Junior and Senior Developers
Programming with Mosh
Step-by-step ASP.NET MVC Tutorial for Beginners | Mosh
Programming with Mosh
[Pluralsight]: Become a Full-stack .NET Developer
Programming with Mosh
Xamarin Forms Tutorial: Build Native Mobile Apps with C#
Programming with Mosh
Value Types and Reference Types in JavaScript
Programming with Mosh
Using Redux in Angular 2+ Apps | Mosh
Programming with Mosh
Testing Angular 2+ Apps with Jasmine and Karma | Mosh
Programming with Mosh
Profile and optimize your Angular 2 apps
Programming with Mosh
Build a Real-world App with ASP.NET Core and Angular 2
Programming with Mosh
Entity Framework 6 Tutorial: Learn Entity Framework 6 from Scratch
Programming with Mosh
Two-way Binding and ngModel in Angular 4
Programming with Mosh
Udemy Live 2017: Teaching Tech Panel
Programming with Mosh
Demo of An E-commerce App Built with Angular, Firebase and Bootstrap 4
Programming with Mosh
My Brand New Angular Course
Programming with Mosh
TypeScript Tutorial - TypeScript for React - Learn TypeScript
Programming with Mosh
Access Modifiers in TypeScript
Programming with Mosh
TypeScript Interfaces
Programming with Mosh
TypeScript Classes
Programming with Mosh
TypeScript Constructors
Programming with Mosh
TypeScript Properties
Programming with Mosh
Angular Tutorial for Beginners: Learn Angular & TypeScript
Programming with Mosh
AngularJS vs Angular 2 vs Angular 4 | Mosh
Programming with Mosh
Angular Material Tutorial | Mosh
Programming with Mosh
Angular Animations Tutorial | Mosh
Programming with Mosh
Firebase in Angular Applications | Mosh
Programming with Mosh
Deploying Angular Applications | Mosh
Programming with Mosh
Building Forms in Angular Apps | Mosh
Programming with Mosh
Directives in Angular Applications
Programming with Mosh
Routing and Navigation in Angular | Mosh
Programming with Mosh
Angular 4 in 40 Minutes
Programming with Mosh
[NEW COURSE] Unit Testing for C# Developers
Programming with Mosh
Unit Testing C# Code - Tutorial for Beginners
Programming with Mosh
C# Classes Tutorial | Mosh
Programming with Mosh
C# Object Initializers Tutorial
Programming with Mosh
C# Constructors Tutorial | Mosh
Programming with Mosh
More on: Systems Design Basics
View skill →Related Reads
📰
📰
📰
📰
ArborDb: a Rust document store where reading one field doesn't get slower as the record grows
Dev.to · Frédéric Meyer
The 2026 World Cup: A Stress Test For Enterprise Intelligence
Forbes Innovation
Why Interoperability Can Be A Tough Sell In Manufacturing
Forbes Innovation
Introduction: What are Design Patterns and Why Should You Care?
Dev.to · Manoj Khatri
🎓
Tutor Explanation
DeepCamp AI