1 00:00:00,000 --> 00:00:05,050 [SOUND]. 2 00:00:05,050 --> 00:00:08,184 Hi, I'm Dean, and I'm a software engineer. 3 00:00:08,184 --> 00:00:11,380 Writing software is a rewarding but difficult job. 4 00:00:11,380 --> 00:00:15,110 Luckily, we have tools like Visual Studio to help us along the way. 5 00:00:15,110 --> 00:00:16,130 Like any other tool, 6 00:00:16,130 --> 00:00:19,620 your level of efficiency will be determined by how you use it. 7 00:00:19,620 --> 00:00:22,960 In this workshop, we're going to go over some tips and tricks that will save you 8 00:00:22,960 --> 00:00:27,730 time and put you on the path to becoming a Visual Studio power user. 9 00:00:27,730 --> 00:00:31,260 Let's get started with something that you'll spend a lot of your career doing, 10 00:00:31,260 --> 00:00:32,850 navigating projects and code. 11 00:00:34,070 --> 00:00:36,900 If you're anything like me, you'll probably find yourself in a state 12 00:00:36,900 --> 00:00:40,610 where you have quite a few tabs open in Visual Studio at any given time. 13 00:00:40,610 --> 00:00:44,060 The ability to manage these tabs efficiently will help you immensely when, 14 00:00:44,060 --> 00:00:48,480 for example, you're switching between an HTML file and a CSS file that affects it. 15 00:00:49,690 --> 00:00:51,110 Keyboard shortcuts are a quick and 16 00:00:51,110 --> 00:00:55,470 natural way to manage your tabs without taking your hands off your keyboard. 17 00:00:55,470 --> 00:00:56,990 If I hold the control key down and 18 00:00:56,990 --> 00:01:01,950 press tab once, I'll see a list of currently open tabs and tool windows. 19 00:01:01,950 --> 00:01:04,830 My current tab shows up at the top of the list followed by my 20 00:01:04,830 --> 00:01:08,580 other open tabs in the order in which they most recently had focus. 21 00:01:08,580 --> 00:01:11,820 When I release the control key, the highlighted tab will gain focus. 22 00:01:12,960 --> 00:01:16,260 Since my previously focused tab is now position two, 23 00:01:16,260 --> 00:01:20,140 I can quickly switch back to it by pressing Ctrl+Tab again. 24 00:01:20,140 --> 00:01:22,738 To close a tab, press Ctrl+F4. 25 00:01:22,738 --> 00:01:26,450 If your tabs become too cluttered, you can close all but 26 00:01:26,450 --> 00:01:31,800 one by right clicking on the tab you wish to keep, and selecting close all but this. 27 00:01:31,800 --> 00:01:34,850 If you want to get rid of all of your tabs, right click on a tab and 28 00:01:34,850 --> 00:01:36,570 select close all documents. 29 00:01:38,630 --> 00:01:42,470 Next we're going to check out navigate backward and navigate forward. 30 00:01:42,470 --> 00:01:45,590 You can use these buttons if you prefer them over keyboard shortcuts. 31 00:01:46,790 --> 00:01:49,506 I like keyboard shortcuts, so I'm going to use those. 32 00:01:53,987 --> 00:01:57,352 I'm curious about this method, so I'm going to navigate to definition and 33 00:01:57,352 --> 00:01:57,990 check it out. 34 00:01:59,950 --> 00:02:04,670 With my curiosity satisfied, I want to go back to exactly where I was previously at. 35 00:02:04,670 --> 00:02:08,750 Navigate backward control hyphen, will bring my cursor back to where I left off. 36 00:02:10,930 --> 00:02:13,730 Navigate forward control shift hyphen, 37 00:02:13,730 --> 00:02:15,780 will bring my cursor forward to history again. 38 00:02:17,780 --> 00:02:21,910 Visual Studio tries to only remember interesting changes, which means that if I 39 00:02:21,910 --> 00:02:25,690 only move my cursor one line away, it won't create a new history entry. 40 00:02:28,640 --> 00:02:31,730 Sometimes we have to deal with extremely large files. 41 00:02:31,730 --> 00:02:34,880 Outlining is designed to make this task more manageable by collapsing and 42 00:02:34,880 --> 00:02:35,540 expanding text. 43 00:02:36,640 --> 00:02:41,510 Take this large class for instance, just scrolling through it is time consuming. 44 00:02:41,510 --> 00:02:46,210 Let's see what happens when I collapse to definitions by holding the control key and 45 00:02:46,210 --> 00:02:47,279 pressing M then O. 46 00:02:50,774 --> 00:02:53,849 Now I can easily scroll through and look at the method definitions. 47 00:02:55,250 --> 00:02:59,200 When I want to expand text that has been collapsed, I can press the plus icon to 48 00:02:59,200 --> 00:03:02,420 the left of the text, or put my cursor on the hidden text and 49 00:03:02,420 --> 00:03:07,290 use the keyboard shortcut, Ctrl+M, to toggle outlining expansion. 50 00:03:09,240 --> 00:03:11,852 When developers talk to each other about code, 51 00:03:11,852 --> 00:03:15,462 an easy way to reference specific lines of code is by line number. 52 00:03:15,462 --> 00:03:20,454 Let's say somebody has a question about AccountController.cs line 315. 53 00:03:20,454 --> 00:03:25,010 We can navigate to line 315 using the shortcut go to line. 54 00:03:25,010 --> 00:03:28,240 Press Ctrl+G, input the line number you want to go to, and 55 00:03:28,240 --> 00:03:30,250 press Enter to go there. 56 00:03:30,250 --> 00:03:33,580 Another handy trick is scrolling a document using your keyboard. 57 00:03:33,580 --> 00:03:36,865 If you press the up or down arrow it will move your cursor, but won't scroll 58 00:03:36,865 --> 00:03:39,907 the document unless your cursor is at the top or bottom of the screen. 59 00:03:43,413 --> 00:03:44,702 If you hold the control key, 60 00:03:44,702 --> 00:03:47,300 the up and down arrows immediately scroll the document. 61 00:03:49,660 --> 00:03:53,321 Note that Visual Studio will automatically move the cursor before allowing it to go 62 00:03:53,321 --> 00:03:53,909 off screen. 63 00:03:58,239 --> 00:04:01,380 Find matching brace allows you to navigate between opening and 64 00:04:01,380 --> 00:04:03,330 closing braces or tags. 65 00:04:03,330 --> 00:04:07,290 On this method, I am at the opening brace and I can find the matching, in this case, 66 00:04:07,290 --> 00:04:12,440 closing brace by pressing Ctrl ]. 67 00:04:12,440 --> 00:04:16,350 Note that Visual Studio also highlights the matching brace visually. 68 00:04:16,350 --> 00:04:20,480 The same method can be used to find opening and closing tags in HTML. 69 00:04:20,480 --> 00:04:23,890 This can be really handy with larger HTML files. 70 00:04:23,890 --> 00:04:26,820 Now that you have a feeling for how powerful keyboard shortcuts can be for 71 00:04:26,820 --> 00:04:31,210 navigation, I'm going to show you how to remap your keyboard shortcuts. 72 00:04:31,210 --> 00:04:33,730 Some commands aren't mapped to anything by default, and 73 00:04:33,730 --> 00:04:37,590 others you might want to remap because you don't like their default mapping. 74 00:04:37,590 --> 00:04:42,410 Lets say, I want to map find matching brace to control fb, for find brace. 75 00:04:43,480 --> 00:04:48,610 Go to tools, options, environment, keyboard and search for brace. 76 00:04:51,270 --> 00:04:53,875 We see at the command is named edit.gotobrace. 77 00:04:55,210 --> 00:04:58,520 Put your focus in the press short cut keys text box and 78 00:04:58,520 --> 00:05:00,540 press the shortcut keys you want to assign. 79 00:05:01,670 --> 00:05:03,678 After they show up press assign. 80 00:05:07,312 --> 00:05:10,860 We can now use control F, B, for find matching brace. 81 00:05:12,100 --> 00:05:15,150 Watch out for accidental keyboard shortcut collisions. 82 00:05:15,150 --> 00:05:17,960 If I try to assign control B to this shortcut, 83 00:05:17,960 --> 00:05:20,800 Visual Studio will show me that is already in use. 84 00:05:20,800 --> 00:05:25,767 Assigning control B to find matching brace will remove it from debug.function 85 00:05:25,767 --> 00:05:27,043 breakpoint. 86 00:05:27,043 --> 00:05:28,200 That's it. 87 00:05:28,200 --> 00:05:31,150 With these shortcuts, you should be able to quickly navigate projects and 88 00:05:31,150 --> 00:05:32,640 files with ease. 89 00:05:32,640 --> 00:05:35,700 You're already on your way to becoming a Visual Studio power user, and 90 00:05:35,700 --> 00:05:36,560 we're just getting started. 91 00:05:36,560 --> 00:05:40,530 In the next video, I'll show you how Visual Studio can edit your code for you.