Really surprised not to see Ctrl+r+r in these 10 gems. I use it every minute of the day to rename all occurrences of a variable in a file. Cursor on a variable, Ctrl RR, type the new name, hit enter, no need to check if you forgot any of them (works in comments too)
0:00 - Intro 1:33 - Opening project file in the file explorer & full file path 2:56 - Extracting interfaces (auto properties) 4:08 - Suggesting usings in reference assemblies and NuGet packages 8:50 - F12 or ctrl+F12 11:23 - "Go To..." tips (ctrl+t or ctrl+,) 18:11 - Refactoring tips (ctrl+. or alt+enter) 25:11 - Document format (ctrl+K,D) 27:20 - LINQPad - C# interactive (test out your code) 31:03 - Move around code lines (alt+ arrow keys [up or down]) 33:05 - Find out method parameters (ctrl+shift+space) and bring up IntelliSense (ctrl+j) 35:55 - Change text in multiple lines at once (alignment dependent) (shift+alt +[arrow keys or mouse drag]) 39:06 - some more ctrl+. - matching filename with class name
*Scroll Bar Map* - a navigation one I find really useful: go to _Tools-> Options...->Text Editor->All Languages->Scroll Bars_ and turn on _"Use map mode for vertical scroll bar"_ - your scroll bar is now a mini document map. Makes it really easy to know where you are in larger files and quickly scroll to the right place.
Ctrl + R + R : Rename Rename a variable, property, method, or class. It's easy to remember because of the R (rename). Alt + F + F + 1: Open Recent File I would have loved an open-recent-file shortcut like VS12's ( Ctrl + Shift + Z ), which is no longer a default shortcut. I have resolved to use Alt + F + F + 1. You can replace the number 1 for any of the files in the menu File / Recent Files. i.e. Alt + F + F + 3 opens the 3rd recent file. Tim...thou art the man! Your video tutorials have saved me so much time and, more importantly, sparked curiosity in the topics you cover. Sincerely...Thank you!
Hello Tim, even i am using visual studio and c# for the last ten years, following you videos, i always found tone of tricks that really i don't knew. you are a great man. thanks
Hello Tim. I just started out exploring .NET Core / C# and just wanted you to know that your guidance are truly resourceful. I want to say thanks and appreciate all the effort you've put into making all of them.
An extension to tip #10, if you hold down CTRL + ALT, you can click anywhere on any line to get the same behavior but it doesn't have to be aligned. Another one i really like is CTRL + D, which will replicate the line of code the cursor is on right below it.
FYI, Format Document on VS2019 is Ctrl+K, Ctrl+D. Ctrl+E, Ctrl+D just gives a bell sound. I think this and the refactoring embedded classes to their own file are awesome tips. Thanks Tim!
It depends on how you set up the shortcuts initially (I forget the exact choice that changes this). My VS2019 still is set up as Ctrl+E,D Glad you enjoyed the tips.
Get tips, thanks! When doing the rectangular highlighting, with the mouse, you don't have to hold down the Shift key, just the Alt key. In addition to F12 and Ctrl + F2, I love Alt+F2. It shows the definition in a pop up window below where you are editing. Also, Ctrl + - is great to use to go back to the previous place(s) you were editing. Ctrl + Shift + - does the reverse (after you have hit Ctrl + -)
Tim, I love your videos! I have been coding 30++ years but I am leaning tonnes of things from you. I missed one very useful VS feature: *Ctrl-R* *Ctrl-R* for renaming everywhere, *including* *filenames* . So, instead of renaming a class and then Ctrl-. for refactoring, just do it in one go _and_ make sure all your references are correct as well. I *never* just rename in the editor and then fix the consequences. I let VS take care of everything.
These are great tips, Thank You! (I'm never going to be able to remember all these :D !) Don't think anyone's mentioned this (and yes, I know it's an old video). @37:25 you say you can only use this feature if the locations are in alignment. While this is true for , you can also use and then mouse click on random places in your code and then anything you type is carried out at each discrete location. So, for example, if you want to change the name of a variable, you can use this to click on the start of the variable name everywhere in your code and then start typing (yes, I know this may be a bad example because you'd probably be better using find/replace, but you get what I mean.)
Thanks for sharing! I have seen Tim do that before in other videos. It just must not have made the cut for this one. To help you remember all the tips, look at the video notes (Show More above). A viewer also broke the video into chapters for you so you can jump to the key spots in the video to review.
Additional shortcuts I use on daily basis: CTRL+M+O = Collapse blocks of code of all members (same as if you collapsed them manually one by one using the [ - ] and [ + ] buttons next to the line number CTRL+M+M = Collapse/Expand current block of code CTRL+R+R = same as F2 = Refactor identifier under the cursor CTRL+Up/DownArrow = Move screen one line up/down (while keeping cursor locked at the current line) CTRL+. (dot) on constructor parameter = There is option to "initialize field" - it will create a private member with that type and set it in the body of the constructor... Then you can CTRL+R+R or F2 on the member and rename it to use underscore as prefix CTRL+; (semicolon) = jump to Solution explorer (then using down arrow to navigate the listbox) (use ESC to return to the code - not needed to click with mouse) CTRL+Tab+Arrows (dont release it) = keeps "switch tab" window open and then using the arrow keys you select which tab/window to switch to CTRL+Alt+I = Immediate window - very useful while in break mode when debugging (again, ESCape for return to the code - not needed to click with mouse) CTRL+Alt+O = Output window CTRL+R+G = removes unnecessary using statements CTRL+K+S = Surrounds selected code with ..... (for example, #region, IF statement, etc.) CTRL+K+X = pop up "Insert snippet" window Snippets (write below text and press Tab twice): propf = inserts full property including field prop = inserts auto property ctor = inserts constructor for current class fore = inserts foreach construct #reg = inserts #region ---- #endregion construct
Great video! I didn't know of about half of these and I'll definitely be using the search options more. RE tip 10, you can now have multiple cursors even if they aren't aligned. Hold CTRL+ALT and click anywhere in your document to place a cursor. I use this a lot. You might need to update VS to the latest version though. Oh, and that interactive console is sweet. I had no idea that was there!
Very useful tips thanks, but you missed one very important to me: The F2 key. It practically does the same as your bonus tip with renaming but not afterwards. You just put your cursor on a variable/method/class ... and hit F2 and you can instantly rename it and you get live preview where it will be changed and after hitting enter it will apply.
Tim, I love you for #9 :D It is so often I have to check the signature of a method or to change the method invoked on an object and I have never thought there are shortcuts for this. incredible) I believe everyone has borrowed something from this video Let me share some hotkeys I use frequently alt+F12 gives you a popup with the code instead of taking you to the file with that code ctrl+G search by line instead of ctrl+, prefix : (actually useful when examiningc code from an exception stack trace) ctrl+- takes you to the position of last edit (my personal favourite) ctrl+x cuts entire line (i use it a hundred times a day) ctrl+K,S surrond with (#region, #if, if, for etc.) ctrl+M,M; ctrl+M,L; ctrl+M,O; ctrl+M,P opens/collapses sections of code and here goes wow :) ctrl+TAB switch between opened files - I discovered this just now, while watching this video and playing around with hotkeys:D gonna use it heavily another useful thing - split current window in half by dragging down by an icon at the top of the scroll (just above the up arrow)
Very cool. The only problem I have is that you need to memorize so many shortcuts and a lot of them are multi-key shortcuts (more than two). I forget what I don't use all the time.
Where was this info years ago? Well, right here of course, but I'm just learning now. Shift-Space to bring up method parameters... I had no idea. Ctrl-J to show other methods in the class? Wow. Even simple Alt-Arrows to move one or more lines up and down. Tim, your videos are invaluable for developers of all skill levels, whether simple tips and tricks or complex concepts broken down into simple parts. Thanks for all you do!
My goodness Microsoft, you have done some wonderful things here with the VS IDE. But when you have been using the VS IDE for more than two decades to write millions of code to build/refactor/retire dozens of product lines -- like Microsoft's Engineers have clearly done -- any code editing conveniences sought are inevitably going to make their way into that IDE. And we, outside of Microsoft, benefit from it. And thanks to Tim for pointing these options and conveniences out.
Great video. I've been using Visual Studio since about the early 1800s, yet I learned several things here that I either didn't know about, or had completely forgotten about. I think it's interesting that Ctrl+K/Ctrl+D and Ctrl+E/Ctrl+D do the same thing.
I did some work on VBA, never used it before, but a helpful person on YT pointed me to the Immediate window which I used extensively. So my favourites are the C~ Interactive window and the Shift+ALT, they are going to come in very handy. Thanks Tim :)
Awesome video as usual! Some I knew some I didn't and, to be honest, I have forgotten about some of these amazing features. Looking forward to watching many more videos.
Fantastic video, always appreciate the way you provide multiple examples when teaching. I knew only half of these shortcuts, lots of which I use daily. Picked up CTRL+E+D from a Senior Developer at work, always useful having other team members code with you. Each have their own little tricks/methods of doing things. From the video, CTRL + J and CTRL + Shift + Space will be for me the most useful. Everyday, the IntelliSense appears momentarily then disappears so I retype the last few characters to re-prompt IntelliSense. Knowing this is great! I liked the CTRL + T functionality, nice intuitive/advanced search. I found the CTRL + . functionality interesting, I knew of it and use it frequently, however I didn't know it could be used to do some of the refactoring in the video, such as getting rid of unused namespaces, and moving a class to it's own file. Before I would have created a new class and copied it across, like you outlined. The interactive C# window is a nice feature, didn't know of it, usually use LINQ Pad however, may find myself using this now, in certain situations. Thanks for making these videos, always appreciated!
Thanks Sir..I knew one additional which is ctrl +k k which will bookmark line number and user can able to find all bookmarks with ctrl+k , ctrl +w which helps lot
completely forgot about the damn options in VS. you have easily increased my productivity three-fold. a few i use daily, like the alt+arrows. document formatting, also my favorite command combo is "Ctrl+M, +O" which collapses document. and now that i know about options again, lol, there's even a box to make regions collapsible with the same command.
The most satisfying ones are: Ctrl+K,C and Ctrl+K,U for commenting and uncommenting big lines of code! Write down each one of these then followed by TAB, TAB (these definitely save you big time!): ctor, prop, propg, propfull, for, foreach, try, tryf Ctrl+K,X to access all those code snippetsAlt+B+U (Build Project), Alr+B+B (Build solution) MS has been extremely consistent on keyboard shortcuts since decades!
Those are nice. I just wish the ones I want weren't behind two keys. I could re-map them but then I'd have to let everyone know that I did. I still might do it for some things.
Love these top x videos as there is always one you don't know. In this case for me it was #7, Interactive Window. However the Show Intellisense is a a close 2nd because I always forget the shortcut keys for it :) #6 - Formatting code, I would highly recommend the "Productivity Power Tools" extension - it has a "Format document on save" option and remove/sort usings on save. Great little tool, plus other useful features! Great video Tim, thanks for doing this!
As always awesome content. Column mode copy paste is an adventure as well and all column mode is hugely useful. I write vary complex systems and employ the same logic which requires the same code so column based edit or copy paste saves a lot of time. Thanks Tim for your effort and content.
Another quick point on the Go To Implementation feature: if you're using it in a situation where there are multiple valid choices (e.g., some interfaces and abstract classes), VS will open a window in the same place as the Output, Warnings, etc. windows that lets you choose which implementation to go to.
I know this is old video but for the last gem you can just hold alt and hold click while moving the mouse to box select from your mouse cursor. This also works with other editing software like notepad++. Thanks for the info.
Thanks again for the video Tim. My Resharper trial just expired and I was considering subscribing. However, after watching this video I realized there are several cool features right in Visual Studio that would most likely serve my needs satisfactorily. My favourite by far is the interactive window !!!!
Excellent! I am glad you are checking out the great features built into Visual Studio. The Visual Studio team has been working hard to provide an amazing product.
Ctrl J is indeed helpful. I knew most of the others, as I work with shortcuts a lot, but still great video. [C# Interactive] is also awesome. I was using [Immediate Window] until now, but there is no IntelliSense there. So thank you for that one as well. Few suggestions from me (small tips) about 1) How to scroll up/down without a mouse: Click somewhere in the code, and then Ctrl Up/Down arrow. It scrolls the screen without moving your cursor's position. 2) Cut a line of code without selecting and without the mouse at all: Put your cursor on the line you want to cut and Shift + Del. Entire line is gone (but is available in the clipboard for pasting). So Ctrl+V pasts that line where ever you want. Probably most of the developers already know these, but I still hope someone would find them helpful. Thank you.
One is from me :) when you select a word, you can find all the occurrences in that document with ALT + Shift + . combination. When you hold ALT + Shift then by pressing. you can select all of them. It's also useful sometimes.
Didn't know 1, 4, 6, 7, 8, and the Ctrl + J part of 9. Gotta say, I do manually what Ctrl + J does automatically so often, as well as the ability to move lines with Alt + Arrows. These are gonna be extremely helpful to know! Thanks for the videos as always!
Thank you Tim. These cool features should definitely reduce my time going forward. The one which I can use the most would be C# interactive and Shift+Alt+up/down arrow
Try installing CodeMaid extension. Then set is options to auto format and clean your code on save. Use it for years and consider it invaluable and the best extension.
Thanks for the recommendation. I typically don't use extensions as much as possible since I don't want the extensions to be a distraction for my videos. However, I'm putting together a list of helpful extensions and this will probably make the list. Thanks again.
I hope this little trick I found helps people out. It definitely stems from my focus on my preferred usage of the keyboard over the mouse ... everywhere ... not just in Visual Studio. If your cursor is somewhere either within a statement or touching the very beginning or end, your can hold down the Control key and press w a couple of times and the selection expands with each pressing of the w key. Recently while taking Tim's SQLite Start to Finish course, I noticed that for reasons unbeknownsed to me (I certainly did not type them, nor where they in Tim's recording of the video) in the xaml coding for the forms there were column span statements. Since they weren't part of the code I wanted those out of there. Easy, place the cursor either in or at the begin/end, hold Ctrl and three quick presses on the w key, press delete and its done. I do hope its w as well for people with other regional settings on their system than mine. Formatting the document using Ctrl + E, D for example which was a familiar feature of VS to me, but with Dutch regional settings I need to use Ctrl + K, D
Tim...awesome video as always!!! Would you consider doing a video on creating your own custom controls/forms that you can save as templates for future projects?
Old comment but I think Ctrl+K Ctrl+D is for those of us who keep upgrading visual studio, because The E version doesn't work for me but I use KD all the time
Didn't know about Ctrl+,/Ctrl+T, format document, and Ctrl+J (probably my favourite of all ten, that and format document) and Ctrl+Shift+Space! Those are gonna come in handy for sure
Very nice, didn't know about the Go To search. I think one thing you've missed is the very powerful rename feature (F2). It's what I thought near the end of the video when you renamed a class name. I believe it even renames the filename as well when renaming a class. Using F2 it will also rename all references to it. But nonetheless awesome video, very useful, thanks!
Ctrl + . is really great and powerful. The column selection tip (last one) can also be used just with alt, and can be enhanced by using cut/copy and paste. For example, if you have a in text editor (like Notepad++ that also allows column selection) a list of strings to put in the Console.WriteLine argument, you can copy and paste inside the double quotes and it will fill all the lines, even if your strings have different lengths.
Ctrl j was new to me, thanks 🙂 Addition from me, 3 drop-downs at top in any file for assembly, class, functions/member properties... Super handy and they are sorted alphabetically
Great tips ! The Alt + Up or Down To move a bloc of code is awesome. The interactive C# can also be welpful. But they are all great anyway ! Thanks Tim ! :-)
another useful tip is that you can quickly type method names by just typing the uppercase characters in the name. So, type Console.WL for Console.WriteLine. Handy for the names that are a million characters long. (of course you can get the wrong name selected but it is easy to pick from the list that pops up.)
Things I didn't know about: Ctrl-T, Alt-Up/Down, Rectangle Highlighting (though I kinda thought VS had it somewhere, just didn't know how easy it was). Ctrl-Click on method/whatever is another biggie for me. That'll be a big time-saver. I always used to just use right-click Go To Definition. I knew F12 was there, I just didn't really use it. Ctrl-Click will be much faster than either! Two things that come to mind that I use which you didn't highlight here: Rename Class and File together: instead of renaming the class in your code, then renaming it via Ctrl-., just rename it in the Solution Explorer. As long as the names started off matching, Solution Explorer will prompt you if you want to rename both the class and the file. Say Yes, and it'll rename both. If they don't match, though, then Ctrl-. is the faster way to go. Snippets: these are probably a whole presentation on their own (which I'd love to see, if you don't already have one that I missed). When I first started in C#, I dismissed snippets as fairly useless for someone who types reasonably fast. After all, what's the point of pressing a bunch of keys to get a simple if/else block, then having to cursor back up and fill them all in when autocomplete and plain old typing will do it a lot faster and in the proper order. But a lot of snippets are more interactive, like the switch snippet which offers the option to fill in every possible option if you're switching on an enumeration variable. I'm still discovering what snippets are actually useful, but they're definitely not something that should be dismissed as quickly as I originally did.
Snippets are really awesome. I use them all the time and try to point them out (if, try, prop, propfull, etc.) I'll definitely be doing a video on them in the future. It will include how to create your own snippets.
One more gem i really like. Sometime when debuggering as our objects get populated there might be some specific properties that we are more interested in, say the class's key values or say a count or a datetime value. Let's call these the main values of interest for a given class/object the we want to know say 90% of the time of what makes the object meaningful... You may decorate your classes with an attribute to tell Visual Studio what you want to see in the debug watch window. Enough talking... :) [DebuggerDisplay( "{Property1} {Value2} {Description}" )] public class MyClassToShowCustomerDebugInfo { string Property1 { get ; set } int Value2 { get ; set;} public MyClass foo { get; set;} string Description { get; set; } /* More goo... */ } main() { MyClassToShowCustomerDebugInfo checkThisOut = new ...; } So let's add the variable "checkThisOut" to the debug window. Now look at the the variable in the debug watch window., should now see the value for thte instance variable as you specified in the interpolated string you define, Also is did puput in a string label, but you can do that too so "Value2 = {Value2} Desc = {Description"}" the value will be shown as you would expect. Easy and simple and so helpful for the most common cases, should see that you may still drill into the object just as you normally would... Enjoy :)
My favorite gem not touched, in the article is code snippets. The one i really like if switch. When you start a switch for an enum get just: switch Now press "TAB" (might need to press "ESC" to get rid fo the intellisennse window. But once the code snippet is invoked you enter either an enum or a variable that is an enum type then press enter, should get a case for each value in the enum... Simple example: public enum Foo { One = 1, Two = 2, Default = 0 } public void Test() { switch(Foo) { case Foo.One: break; case Foo.Two: break; case Foo.Default: break; default: break; } }
CTRL + . is the most used one. But there is one more useful option that is "Show Clipboard HIstory" which allows you to paste something which you have copied earlier.
Enjoyed this. Will implement it in future. 1) Is there any shortcut or better ways to deal with references/assemblies? Sometimes we need to update the references (sql or 3rd party) in our projects and we have change it manually in each one. Is there any easier way ? 2) Could you please also do a session on best practices while using GIT ? Thank you.
I think it is a matter of which set of shortcuts you use. I believe in this video, my shortcuts had been upgraded from old enough versions of Visual Studio that they were different than the new defaults. I've sinced fixed that.
These are great tips, but the problem I've always had was that you can get old and gray trying to remember them. If you search for "Cheat Sheet Visual Studio 2017", you'll see a list of the shortcuts. After a while you will remember the ones you use.
I even adjusted the Class Template (for VS2019: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs") to get rid of all those unused usings and put public in front of class instead of re-typing it every time I make a new class
For some reason, my my reformat document is Ctrl+K Ctrl+D, I have no memory of remapping it, but I've been using it for ages, and Ctrl+E Ctrl+D does nothing. Odd.
Great video first of all! You've showed a very nice way to clean up the using statements but is there also a quick way to clean the References inside your project?
Great video. Another useful one is clipboard history, Ctrl+Shift+V, which shows the last 10 things copied.
Did you know Windows has one as well? Win+V
@@IAmTimCorey The one for Windows needs to be turned on in settings. But, once it's turned on it can be used in VS, Word, Excel, etc.
Really surprised not to see Ctrl+r+r in these 10 gems. I use it every minute of the day to rename all occurrences of a variable in a file. Cursor on a variable, Ctrl RR, type the new name, hit enter, no need to check if you forgot any of them (works in comments too)
Holy wow, you have no idea how much time you will have saved me
0:00 - Intro
1:33 - Opening project file in the file explorer & full file path
2:56 - Extracting interfaces (auto properties)
4:08 - Suggesting usings in reference assemblies and NuGet packages
8:50 - F12 or ctrl+F12
11:23 - "Go To..." tips (ctrl+t or ctrl+,)
18:11 - Refactoring tips (ctrl+. or alt+enter)
25:11 - Document format (ctrl+K,D)
27:20 - LINQPad - C# interactive (test out your code)
31:03 - Move around code lines (alt+ arrow keys [up or down])
33:05 - Find out method parameters (ctrl+shift+space) and bring up IntelliSense (ctrl+j)
35:55 - Change text in multiple lines at once (alignment dependent) (shift+alt
+[arrow keys or mouse drag])
39:06 - some more ctrl+. - matching filename with class name
Thanks! Someone already beat you to it. I have similar timecodes in the description.
@@IAmTimCorey I noticed. After... :)
Still. More videos to go, as I watch them :)
*Scroll Bar Map* - a navigation one I find really useful: go to _Tools-> Options...->Text Editor->All Languages->Scroll Bars_ and turn on _"Use map mode for vertical scroll bar"_ - your scroll bar is now a mini document map. Makes it really easy to know where you are in larger files and quickly scroll to the right place.
Excellent, thanks for sharing!
Ctrl + R + R : Rename
Rename a variable, property, method, or class. It's easy to remember because of the R (rename).
Alt + F + F + 1: Open Recent File
I would have loved an open-recent-file shortcut like VS12's ( Ctrl + Shift + Z ), which is no longer a default shortcut. I have resolved to use Alt + F + F + 1. You can replace the number 1 for any of the files in the menu File / Recent Files. i.e. Alt + F + F + 3 opens the 3rd recent file.
Tim...thou art the man! Your video tutorials have saved me so much time and, more importantly, sparked curiosity in the topics you cover. Sincerely...Thank you!
I am glad you enjoyed the video.
Hello Tim, even i am using visual studio and c# for the last ten years, following you videos, i always found tone of tricks that really i don't knew. you are a great man. thanks
Great to hear!
Numbers 1, 4, and 10 were brand new to me and #4 is worth its weight in gold!
Awesome!
Hello Tim. I just started out exploring .NET Core / C# and just wanted you to know that your guidance are truly resourceful. I want to say thanks and appreciate all the effort you've put into making all of them.
Glad to help!
An extension to tip #10, if you hold down CTRL + ALT, you can click anywhere on any line to get the same behavior but it doesn't have to be aligned. Another one i really like is CTRL + D, which will replicate the line of code the cursor is on right below it.
Thanks for sharing.
FYI, Format Document on VS2019 is Ctrl+K, Ctrl+D. Ctrl+E, Ctrl+D just gives a bell sound. I think this and the refactoring embedded classes to their own file are awesome tips. Thanks Tim!
It depends on how you set up the shortcuts initially (I forget the exact choice that changes this). My VS2019 still is set up as Ctrl+E,D Glad you enjoyed the tips.
Get tips, thanks! When doing the rectangular highlighting, with the mouse, you don't have to hold down the Shift key, just the Alt key.
In addition to F12 and Ctrl + F2, I love Alt+F2. It shows the definition in a pop up window below where you are editing.
Also, Ctrl + - is great to use to go back to the previous place(s) you were editing. Ctrl + Shift + - does the reverse (after you have hit Ctrl + -)
I am glad you enjoyed the video.
Tim, I love your videos! I have been coding 30++ years but I am leaning tonnes of things from you.
I missed one very useful VS feature: *Ctrl-R* *Ctrl-R* for renaming everywhere, *including* *filenames* . So, instead of renaming a class and then Ctrl-. for refactoring, just do it in one go _and_ make sure all your references are correct as well. I *never* just rename in the editor and then fix the consequences. I let VS take care of everything.
Thanks for sharing.
These are great tips, Thank You! (I'm never going to be able to remember all these :D !)
Don't think anyone's mentioned this (and yes, I know it's an old video).
@37:25 you say you can only use this feature if the locations are in alignment. While this is true for , you can also use and then mouse click on random places in your code and then anything you type is carried out at each discrete location. So, for example, if you want to change the name of a variable, you can use this to click on the start of the variable name everywhere in your code and then start typing (yes, I know this may be a bad example because you'd probably be better using find/replace, but you get what I mean.)
Thanks for sharing! I have seen Tim do that before in other videos. It just must not have made the cut for this one. To help you remember all the tips, look at the video notes (Show More above). A viewer also broke the video into chapters for you so you can jump to the key spots in the video to review.
Additional shortcuts I use on daily basis:
CTRL+M+O = Collapse blocks of code of all members (same as if you collapsed them manually one by one using the [ - ] and [ + ] buttons next to the line number
CTRL+M+M = Collapse/Expand current block of code
CTRL+R+R = same as F2 = Refactor identifier under the cursor
CTRL+Up/DownArrow = Move screen one line up/down (while keeping cursor locked at the current line)
CTRL+. (dot) on constructor parameter = There is option to "initialize field" - it will create a private member with that type and set it in the body of the constructor... Then you can CTRL+R+R or F2 on the member and rename it to use underscore as prefix
CTRL+; (semicolon) = jump to Solution explorer (then using down arrow to navigate the listbox) (use ESC to return to the code - not needed to click with mouse)
CTRL+Tab+Arrows (dont release it) = keeps "switch tab" window open and then using the arrow keys you select which tab/window to switch to
CTRL+Alt+I = Immediate window - very useful while in break mode when debugging (again, ESCape for return to the code - not needed to click with mouse)
CTRL+Alt+O = Output window
CTRL+R+G = removes unnecessary using statements
CTRL+K+S = Surrounds selected code with ..... (for example, #region, IF statement, etc.)
CTRL+K+X = pop up "Insert snippet" window
Snippets (write below text and press Tab twice):
propf = inserts full property including field
prop = inserts auto property
ctor = inserts constructor for current class
fore = inserts foreach construct
#reg = inserts #region ---- #endregion construct
Thanks for sharing.
Control+k+d format document
Gosh that goto shortcut is pure gold.
I love it. I figured others would too.
CTRL + R, R is one of the best.
Renames all instances of an identifier.
Yep, that's a good one.
Thanks Tim, number 6 in VS 2019 is Ctrl+K, Ctrl+D
It depends. It isn't on my default installation. Different setups can have different shortcuts (which is frustrating).
Ctrl+J was new for me. I'm going to use it from now on.
Great!
Very useful!! I discovered this feature on Notepad++ and since then, if an editor doesn't have it, I found it kind of lacking.
Same here, really useful feature!
Great video! I didn't know of about half of these and I'll definitely be using the search options more.
RE tip 10, you can now have multiple cursors even if they aren't aligned. Hold CTRL+ALT and click anywhere in your document to place a cursor. I use this a lot. You might need to update VS to the latest version though.
Oh, and that interactive console is sweet. I had no idea that was there!
Yeah, I think they released that in 15.8, which came out about three days after I recorded this video. Oh well. Thanks for pointing it out though.
Very useful tips thanks, but you missed one very important to me:
The F2 key.
It practically does the same as your bonus tip with renaming but not afterwards. You just put your cursor on a variable/method/class ... and hit F2 and you can instantly rename it and you get live preview where it will be changed and after hitting enter it will apply.
Thanks for pointing it out. I don't use F2 because I always found it quirky but it is definitely a hidden gem.
Tim, I love you for #9 :D It is so often I have to check the signature of a method or to change the method invoked on an object and I have never thought there are shortcuts for this. incredible)
I believe everyone has borrowed something from this video
Let me share some hotkeys I use frequently
alt+F12 gives you a popup with the code instead of taking you to the file with that code
ctrl+G search by line instead of ctrl+, prefix : (actually useful when examiningc code from an exception stack trace)
ctrl+- takes you to the position of last edit (my personal favourite)
ctrl+x cuts entire line (i use it a hundred times a day)
ctrl+K,S surrond with (#region, #if, if, for etc.)
ctrl+M,M; ctrl+M,L; ctrl+M,O; ctrl+M,P opens/collapses sections of code
and here goes wow :)
ctrl+TAB switch between opened files - I discovered this just now, while watching this video and playing around with hotkeys:D gonna use it heavily
another useful thing - split current window in half by dragging down by an icon at the top of the scroll (just above the up arrow)
Very cool. The only problem I have is that you need to memorize so many shortcuts and a lot of them are multi-key shortcuts (more than two). I forget what I don't use all the time.
So many great tips in here - The C# Interactive window and Shift-Alt to block select are my favorites. Thank you for these videos!
Glad you like them!
Where was this info years ago? Well, right here of course, but I'm just learning now. Shift-Space to bring up method parameters... I had no idea. Ctrl-J to show other methods in the class? Wow. Even simple Alt-Arrows to move one or more lines up and down. Tim, your videos are invaluable for developers of all skill levels, whether simple tips and tricks or complex concepts broken down into simple parts. Thanks for all you do!
My goodness Microsoft, you have done some wonderful things here with the VS IDE. But when you have been using the VS IDE for more than two decades to write millions of code to build/refactor/retire dozens of product lines -- like Microsoft's Engineers have clearly done -- any code editing conveniences sought are inevitably going to make their way into that IDE. And we, outside of Microsoft, benefit from it. And thanks to Tim for pointing these options and conveniences out.
You are most welcome. Thanks for watching.
agree!!!
Great video. I've been using Visual Studio since about the early 1800s, yet I learned several things here that I either didn't know about, or had completely forgotten about. I think it's interesting that Ctrl+K/Ctrl+D and Ctrl+E/Ctrl+D do the same thing.
Excellent!
youre pretty old, bru
Tim, thanks, great. I did not know C# interactive, CTRL+. and CTRL+T. Thanks.
You are welcome.
I did some work on VBA, never used it before, but a helpful person on YT pointed me to the Immediate window which I used extensively. So my favourites are the C~ Interactive window and the Shift+ALT, they are going to come in very handy. Thanks Tim :)
You are welcome.
This is super cool and very helpful. I hardly know 5 of them and rest 5 are new for me. Especially C# interactive💚. Thank you Tim.
Glad it was helpful!
Awesome video as usual! Some I knew some I didn't and, to be honest, I have forgotten about some of these amazing features. Looking forward to watching many more videos.
Glad you enjoyed it!
Fantastic video, always appreciate the way you provide multiple examples when teaching.
I knew only half of these shortcuts, lots of which I use daily. Picked up CTRL+E+D from a Senior Developer at work, always useful having other team members code with you. Each have
their own little tricks/methods of doing things. From the video, CTRL + J and CTRL + Shift + Space will be for me the most useful. Everyday, the IntelliSense appears momentarily then disappears so I retype the last few characters to re-prompt IntelliSense. Knowing this is great! I liked the CTRL + T functionality, nice intuitive/advanced search.
I found the CTRL + . functionality interesting, I knew of it and use it frequently, however I didn't know it could be used to do some of the refactoring in the video, such as getting rid of unused namespaces, and moving a class to it's own file. Before I would have created a new class and copied it across, like you outlined. The interactive C# window is a nice feature, didn't know of it, usually use LINQ Pad however, may find myself using this now, in certain situations.
Thanks for making these videos, always appreciated!
I'm glad you were able to gain some new productivity boosters.
Thanks Sir..I knew one additional which is ctrl +k k which will bookmark line number and user can able to find all bookmarks with ctrl+k , ctrl +w which helps lot
Thanks for sharing.
completely forgot about the damn options in VS. you have easily increased my productivity three-fold. a few i use daily, like the alt+arrows. document formatting, also my favorite command combo is "Ctrl+M, +O" which collapses document. and now that i know about options again, lol, there's even a box to make regions collapsible with the same command.
I'm glad I was able to help you become a lot more efficient in your development.
The most satisfying ones are:
Ctrl+K,C and Ctrl+K,U for commenting and uncommenting big lines of code!
Write down each one of these then followed by TAB, TAB (these definitely save you big time!): ctor, prop, propg, propfull, for, foreach, try, tryf
Ctrl+K,X to access all those code snippetsAlt+B+U (Build Project), Alr+B+B (Build solution)
MS has been extremely consistent on keyboard shortcuts since decades!
Those are nice. I just wish the ones I want weren't behind two keys. I could re-map them but then I'd have to let everyone know that I did. I still might do it for some things.
This is an awesome video Tim, thank you for sharing this knowledge and I hope this one blows up for you
You are welcome.
37:37 - you can do that with CTRL+ALT and Highlight/Select the text
Thank you, your videos are SO helpful! :)
Thanks for the tip!
Love these top x videos as there is always one you don't know. In this case for me it was #7, Interactive Window. However the Show Intellisense is a a close 2nd because I always forget the shortcut keys for it :)
#6 - Formatting code, I would highly recommend the "Productivity Power Tools" extension - it has a "Format document on save" option and remove/sort usings on save. Great little tool, plus other useful features!
Great video Tim, thanks for doing this!
Thanks for the suggestion. I'm glad you got something out of this video.
As always awesome content. Column mode copy paste is an adventure as well and all column mode is hugely useful. I write vary complex systems and employ the same logic which requires the same code so column based edit or copy paste saves a lot of time. Thanks Tim for your effort and content.
You didn't mention ctrl + D, which allows you to copy the line of code without using the clipboard.
I don't use it that much. Thanks for sharing though.
didn't know that one. I knew Ctrl+L which cuts the whole line.
Just landed into this channel. first impression : Awesome !
Welcome! I'm glad you are enjoying the content.
Another quick point on the Go To Implementation feature: if you're using it in a situation where there are multiple valid choices (e.g., some interfaces and abstract classes), VS will open a window in the same place as the Output, Warnings, etc. windows that lets you choose which implementation to go to.
Yep, thanks for pointing that out.
I know this is old video but for the last gem you can just hold alt and hold click while moving the mouse to box select from your mouse cursor.
This also works with other editing software like notepad++.
Thanks for the info.
Thanks for the Tip!
Thanks again for the video Tim. My Resharper trial just expired and I was considering subscribing. However, after watching this video I realized there are several cool features right in Visual Studio that would most likely serve my needs satisfactorily.
My favourite by far is the interactive window !!!!
Excellent! I am glad you are checking out the great features built into Visual Studio. The Visual Studio team has been working hard to provide an amazing product.
You can close tabs with the middle mouse button :)
Thanks, but my middle mouse button is my scroll wheel. When I try, I scroll as well, which then causes other issues.
Love using the middle button to close tabs. Very useful!
Ctrl J is indeed helpful. I knew most of the others, as I work with shortcuts a lot, but still great video. [C# Interactive] is also awesome. I was using [Immediate Window] until now, but there is no IntelliSense there. So thank you for that one as well.
Few suggestions from me (small tips) about
1) How to scroll up/down without a mouse:
Click somewhere in the code, and then Ctrl Up/Down arrow.
It scrolls the screen without moving your cursor's position.
2) Cut a line of code without selecting and without the mouse at all:
Put your cursor on the line you want to cut and Shift + Del. Entire line is gone (but is available in the clipboard for pasting).
So Ctrl+V pasts that line where ever you want.
Probably most of the developers already know these, but I still hope someone would find them helpful.
Thank you.
Thanks for sharing.
One is from me :) when you select a word, you can find all the occurrences in that document with ALT + Shift + . combination. When you hold ALT + Shift then by pressing. you can select all of them. It's also useful sometimes.
Thanks for sharing the tip!
Didn't know 1, 4, 6, 7, 8, and the Ctrl + J part of 9. Gotta say, I do manually what Ctrl + J does automatically so often, as well as the ability to move lines with Alt + Arrows. These are gonna be extremely helpful to know! Thanks for the videos as always!
Awesome!
I learned dotnet core 3 with your video in 40 minutes. Thanks alot.
Great to hear!
This is so good. Thank you.
You are welcome.
Thank you Tim. These cool features should definitely reduce my time going forward. The one which I can use the most would be C# interactive and Shift+Alt+up/down arrow
I am glad you found them helpful.
Try installing CodeMaid extension. Then set is options to auto format and clean your code on save. Use it for years and consider it invaluable and the best extension.
Thanks for the recommendation. I typically don't use extensions as much as possible since I don't want the extensions to be a distraction for my videos. However, I'm putting together a list of helpful extensions and this will probably make the list. Thanks again.
I didn't know about CTRL + J. Thanks Tim! I think I'm going to use it a lot :)
Excellent!
I hope this little trick I found helps people out. It definitely stems from my focus on my preferred usage of the keyboard over the mouse ... everywhere ... not just in Visual Studio.
If your cursor is somewhere either within a statement or touching the very beginning or end, your can hold down the Control key and press w a couple of times and the selection expands with each pressing of the w key. Recently while taking Tim's SQLite Start to Finish course, I noticed that for reasons unbeknownsed to me (I certainly did not type them, nor where they in Tim's recording of the video) in the xaml coding for the forms there were column span statements. Since they weren't part of the code I wanted those out of there. Easy, place the cursor either in or at the begin/end, hold Ctrl and three quick presses on the w key, press delete and its done.
I do hope its w as well for people with other regional settings on their system than mine. Formatting the document using Ctrl + E, D for example which was a familiar feature of VS to me, but with Dutch regional settings I need to use Ctrl + K, D
Yep, that's a good one.
I'm glad contribute the other way around for a change.
I did not now about c# intereactive dialog, currently using it at work now. thanks Tim.
Awesome!
Nice work.. Great video.. I appreciate your work and effort tim, Please keep up the good work..
Thank you.
Tim...awesome video as always!!! Would you consider doing a video on creating your own custom controls/forms that you can save as templates for future projects?
Custom controls are coming in the future at some point.
Super useful Gems!! Great video as always!
No.10 - Multi-Cursor (Shift+Alt+Up/Down Arrow) ,
1) Just press and hold Alt + click and drag
will also do the tick
Thanks for the Tip.
Awesome options to know, Thank you very much for mining these gems for us.
You are most welcome. Thanks for watching.
@@IAmTimCorey Could you please make something about design patterns like Singleton, Factory etc.
It is on the suggestion list. Thanks!
Hey Tim, For the code formatting we can also use Ctrl + K and Ctrl + D.
Appreciate the great video.
You are welcome.
Old comment but I think Ctrl+K Ctrl+D is for those of us who keep upgrading visual studio, because The E version doesn't work for me but I use KD all the time
Didn't know about Ctrl+,/Ctrl+T, format document, and Ctrl+J (probably my favourite of all ten, that and format document) and Ctrl+Shift+Space! Those are gonna come in handy for sure
Excellent!
Very nice, didn't know about the Go To search. I think one thing you've missed is the very powerful rename feature (F2). It's what I thought near the end of the video when you renamed a class name. I believe it even renames the filename as well when renaming a class. Using F2 it will also rename all references to it. But nonetheless awesome video, very useful, thanks!
That is a nice feature as well.
Ctrl + . is really great and powerful. The column selection tip (last one) can also be used just with alt, and can be enhanced by using cut/copy and paste. For example, if you have a in text editor (like Notepad++ that also allows column selection) a list of strings to put in the Console.WriteLine argument, you can copy and paste inside the double quotes and it will fill all the lines, even if your strings have different lengths.
Thanks for the tip.
c# interactive window is really nice and I didn't know !
I'm glad you learned about it.
Ctrl j was new to me, thanks 🙂
Addition from me, 3 drop-downs at top in any file for assembly, class, functions/member properties... Super handy and they are sorted alphabetically
Glad it helped!
Hi Tim, Number 7 and 9 are new to me. Thank a lot!
Great!
Great tips ! The Alt + Up or Down To move a bloc of code is awesome. The interactive C# can also be welpful. But they are all great anyway ! Thanks Tim ! :-)
You are welcome.
Now i know there are lots of hidden feature in vs...thank a lots tim corey
You are welcome.
I can't believe I didn't know ctrl+T, that is amazing!
I am glad you learned something new.
another useful tip is that you can quickly type method names by just typing the uppercase characters in the name. So, type Console.WL for Console.WriteLine. Handy for the names that are a million characters long. (of course you can get the wrong name selected but it is easy to pick from the list that pops up.)
Yep, that's a good one too. I use that one a lot, although for Console.WriteLine, you can use the "cw" snippet (type cw and tab twice).
Another useful video. Thank you so much Tim.
You are welcome.
CTRL+R R to rename variables and classes and all its references - very usefull
I'm glad.
Things I didn't know about: Ctrl-T, Alt-Up/Down, Rectangle Highlighting (though I kinda thought VS had it somewhere, just didn't know how easy it was). Ctrl-Click on method/whatever is another biggie for me. That'll be a big time-saver. I always used to just use right-click Go To Definition. I knew F12 was there, I just didn't really use it. Ctrl-Click will be much faster than either!
Two things that come to mind that I use which you didn't highlight here:
Rename Class and File together: instead of renaming the class in your code, then renaming it via Ctrl-., just rename it in the Solution Explorer. As long as the names started off matching, Solution Explorer will prompt you if you want to rename both the class and the file. Say Yes, and it'll rename both. If they don't match, though, then Ctrl-. is the faster way to go.
Snippets: these are probably a whole presentation on their own (which I'd love to see, if you don't already have one that I missed). When I first started in C#, I dismissed snippets as fairly useless for someone who types reasonably fast. After all, what's the point of pressing a bunch of keys to get a simple if/else block, then having to cursor back up and fill them all in when autocomplete and plain old typing will do it a lot faster and in the proper order. But a lot of snippets are more interactive, like the switch snippet which offers the option to fill in every possible option if you're switching on an enumeration variable. I'm still discovering what snippets are actually useful, but they're definitely not something that should be dismissed as quickly as I originally did.
Snippets are really awesome. I use them all the time and try to point them out (if, try, prop, propfull, etc.) I'll definitely be doing a video on them in the future. It will include how to create your own snippets.
For goto to line I use CTRL+G and for format document I use CTRL+K+D, but a lot of other stuff, I did not know
I am glad it was so helpful.
One more gem i really like. Sometime when debuggering as our objects get populated there might be some specific properties that we are more interested in, say the class's key values or say a count or a datetime value. Let's call these the main values of interest for a given class/object the we want to know say 90% of the time of what makes the object meaningful...
You may decorate your classes with an attribute to tell Visual Studio what you want to see in the debug watch window. Enough talking... :)
[DebuggerDisplay( "{Property1} {Value2} {Description}" )]
public class MyClassToShowCustomerDebugInfo
{
string Property1 { get ; set }
int Value2 { get ; set;}
public MyClass foo { get; set;}
string Description { get; set; }
/* More goo... */
}
main()
{
MyClassToShowCustomerDebugInfo checkThisOut = new ...;
}
So let's add the variable "checkThisOut" to the debug window.
Now look at the the variable in the debug watch window., should now see the value for thte instance variable as you specified in the interpolated string you define, Also is did puput in a string label, but you can do that too so "Value2 = {Value2} Desc = {Description"}" the value will be shown as you would expect. Easy and simple and so helpful for the most common cases, should see that you may still drill into the object just as you normally would...
Enjoy :)
Nice! Thanks for sharing.
My favorite gem not touched, in the article is code snippets. The one i really like if switch.
When you start a switch for an enum get just:
switch
Now press "TAB" (might need to press "ESC" to get rid fo the intellisennse window. But once the code snippet is invoked you enter either an enum or a variable that is an enum type then press enter, should get a case for each value in the enum... Simple example:
public enum Foo
{
One = 1,
Two = 2,
Default = 0
}
public void Test()
{
switch(Foo)
{
case Foo.One:
break;
case Foo.Two:
break;
case Foo.Default:
break;
default:
break;
}
}
That is really nice.
Ctrl + F12 🔥. Thank you.
You're welcome!
its CTRL +K+D now for format
Thanks for the tip
Ctrl E+D still works
CTRL + . is the most used one. But there is one more useful option that is "Show Clipboard HIstory" which allows you to paste something which you have copied earlier.
Do you mean CTRL + Shift + V?
*TIP:* You can hold *CTRL+ALT and click* anywhere in the code to place additional cursors in VS2019 at least.
Thanks for sharing.
@@IAmTimCorey My pleasure and thank you for your awesome videos, they are highly appreciated.
Great one!
Awesome video as always, #6 on mine is Ctrl+k, Ctrl+d.
Yep, there are apparently different shortcut schemes that you can implement.
Open .cs file Use Ctrl + G -> Enter the number it will take to the particular line number.
Thanks for sharing.
Enjoyed this. Will implement it in future.
1) Is there any shortcut or better ways to deal with references/assemblies?
Sometimes we need to update the references (sql or 3rd party) in our projects and we have change it manually in each one. Is there any easier way ?
2) Could you please also do a session on best practices while using GIT ?
Thank you.
NuGet is the solution for updating references. It makes it easier to do. As for git best practices, I can add that suggestion to the list.
Ctrl+E, D is changed to Ctrl+K,D in VS 2019.
Thanks for the tip
Ctrl+E, D still available in 2019 (K,D also works)
The "Format Document" shortcut has changed to Ctrl+K, Ctrl+D in VS 2019 (16.9.4). It's still under the "Edit >> Advanced" menu though.
The last tip is very useful, thanks!
You are most welcome. Thanks for watching.
i was surprised to find out that i actually know a few of these :D
Awesome!
For newcomers to this video the Ctrl + E + D trick in Vusual Studio 2022 is Ctrl + K + D. It changed for some reason.
I think it is a matter of which set of shortcuts you use. I believe in this video, my shortcuts had been upgraded from old enough versions of Visual Studio that they were different than the new defaults. I've sinced fixed that.
Excellent... I think you just doubled my coding speed.
Glad I could help!
These are great tips, but the problem I've always had was that you can get old and gray trying to remember them. If you search for "Cheat Sheet Visual Studio 2017", you'll see a list of the shortcuts. After a while you will remember the ones you use.
I definitely recommend only focusing on the ones you use. I don't remember them all, just the ones I need.
I didn't know: 1, 2, 8, 9
I use all the time: 3, 5, 6, 10
Favorite new tip: *8* (hands down freaking awesome!)
Excellent! I'm glad it was helpful.
Hi Tim, number 9 is new to me. Thanks about that
Glad to help!
Thanks for Very helpful tricks. Didn't knew Ctrl+T
You are welcome.
In VS 2022 the "Format document on save" option is now available. Instead of using shortcuts you can format the document by saving it.
That is a nice addition, for sure.
Where is this setting?
Great Video. Thank you for posting.
You are welcome.
I even adjusted the Class Template (for VS2019: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs") to get rid of all those unused usings and put public in front of class instead of re-typing it every time I make a new class
Great. You can also create your own item templates if you don't want to mess with the built-in ones: ruclips.net/video/3uYN3mDFP-o/видео.html
For some reason, my my reformat document is Ctrl+K Ctrl+D, I have no memory of remapping it, but I've been using it for ages, and Ctrl+E Ctrl+D does nothing. Odd.
Yeah, I haven't figured out the reason but it seems like half use ED, half use KD.
Same here
One more tip - you can drag a oiece of code to the ToolBox window, and after paste it back somewhere
Thanks for sharing.
Amazing tips.... Thanks Tim
You are welcome.
Great video first of all!
You've showed a very nice way to clean up the using statements but is there also a quick way to clean the References inside your project?
Not that I know of.
Is there a way to exclude commented code during a search?
CTRL+D
Yep.
Easily the ctrl shift space to see the parameters. I will use that all the time now. I used to delete and retype the parens to make the list pop up.
We've all been there. I'm glad you got something out of the video.