Transcript: Visual Studio .NET - Top 10 Code Editor Tips and Tricks
Hi, my name is Ari Bixhorn, I’m a Lead Program Manager on Visual Studio.NET, you may have seen me on VB TV. And today I wanted to talk a little bit about some of the tips and tricks that you can do within the Visual Studio.NET IDE. The VS core team has done a really awesome job at providing shortcuts and a bunch of new productivity features within the IDE that will allow you to be more productive in your coding experience. So I’ve got sort of a top ten list I wanted to go through today.
All right, so let’s start off at the top. Number 10, custom task list tokens, okay, so the task list is great because it provides you with information about build errors, annotations that you leave for yourself in your code, and by default there are some default tokens that you can leave for code annotations. There’s a to do token, so if you need to finish up a procedure or if you have a bug in your code, these are built in as part of Visual Studio.NET. But what you can actually do is create your own custom tokens for bugs, for notes that you want to leave to other developers on your team and so on, and you can leave these custom task list tokens, you can create them, by going to the tools menu, dropping down and selecting options, and then it’s within the tools options dialog box that you can create your own task list tokens.
So that’s the first thing that’s pretty cool I like to do in the IDE. What is next? Backward and forward navigation, okay, so in Internet Explorer you know we can go backward and forward from page to page, very easy to navigate that way, and we actually have a similar concept within the code editor in Visual Studio.NET so that if you want to navigate backward in your code our code editor actually keeps track of that and there’s a shortcut key that you can press to do this. If you want to navigate backward in your code you can go ahead and press control and then the hyphen key and that will navigate backward to the various places that you’ve been in your code.
One thing to point out here, all of these keyboard shortcuts that I’m talking about here assume that you have the Visual Studio Developer Profile set and you can set that profile under the help menu on your start page.
Okay, so we’ve got custom task list tokens, we’ve got backward and forward navigation, let’s see, we’ve got incremental search. This is kind of cool. Normally when you go ahead and press control F and you want to search for a particular string in your code you have to type in the entire string and then you can just search throughout your code to go ahead and find that. Incremental search is a little bit different, you press control and then the letter I and what that allows you to do is as you’re typing in the code editor will move around finding out each instance of the text that you’ve already typed. So that’s a slightly different pretty cool way to do searching.
All right, what else do we have, we’ve got bookmarks, okay, bookmarks is another way to leave little breadcrumbs in your code if you will. Bookmarks, you can set them very easily, anywhere that you want, let’s say if you’ve got code that you might be jumping back and forward to from time to time, you can leave a bookmark in your code by pressing control K control K and then you can navigate forward and backward within your bookmarks by pressing control K control N, that will move you to the next bookmark, or control K control P, and that will move you to the previous bookmark.
Very closely related to bookmarks are task list shortcuts. Essentially it’s the same concept, except in addition to seeing a little glyph in the margin of your code you actually also see an entry in your task list. So I can right click anywhere in my code and I select add task list shortcut, it’ll leave a little glyph in the margin of my code and it’ll create an entry in my task list.
Okay, so what do we have, we’ve got that, that, that, that and that, task list shortcuts. Ah, the clipboard ring, okay. Clipboard ring, we may know this from using Office, any time you hit control C or you copy some text it adds it to the clipboard ring. And the clipboard ring stores I think up to 20 different code snippets or html markup, things like that. What’s cool in Visual Studio is that we store everything that you have in the clipboard up on the toolbox. Okay, there’s a tab called clipboard ring and you can see all those 20 code snippets that you may have control C’d or copied into the clipboard ring. Now if you want to get access to those and copy any of those into your code you can press control shift and then the letter V and that will go ahead and scroll through everything that you have in your clipboard so that you can find the right snippet and easily drop it into your code.
What else do we have? Number 4, number 4, we have got outlining. Okay, so outlining within the code editor, this is a built-in function of the code editor. It allows you to expand and collapse code regions for things like procedures, classes, etc. So if I want to get just kind of a summary view of all of my code in a particular file I could right click in the code editor and say collapse everything to definitions and what that will do is it will collapse all of your code into just the signature line of it so that you can get more of a summary view of everything that you have in a particular code file.
Okay, so we’ve got clipboard, we’ve got outlining, let’s see, word wrap. Word wrap is kind of cool if you’ve got code that goes too long where you have to scroll off the screen to see the end of your code line. And you can get access to word wrap by pressing control R, control R and what that will do is it will wrap your text around so that you don’t have to do any more horizontal scrolling. Now the only issue with word wrap is that it can make your code look a little bit messy sometimes depending on how you have your code set up, and so word wrap actually works hand in hand with line numbers. So with respect to line numbers you can go ahead and you go to tools options and you can select a checkbox that allows you to see the line numbers of your code as well. This works really well with word warp so that you see where one line ends and the next line begins. Another way to add line numbers to your code is you bring up the macro explorer tool window and there is a macro that’s build in, comes as part of Visual Studio.NET that allows you to turn on and off line numbers very very easily.
So we’ve got word wrap, we’ve got line numbers, last but not least you can now do block selection of text within the code editor. So normally if I want to select several lines of text it’s doing it on a line by line basis, but with block selection I could hold alt, the alt key, while I’m dragging my cursor within the code window and it’ll select it as a rectangle rather than selecting it line by line. What’s another cool way to do selection within the code editor? If I could provide one more little thing that I like to do inside the IDE, it’s very cool, developers, you know, we love to maximize our coding real estate. Visual Studio.NET now supports multi-monitors, so you can have Visual Studio running on one monitor, you can have your application running on another monitor and you can scroll seamlessly between those two. We also have a full screen mode, so I can press shift, alt, enter and it’ll expand Visual Studio into this full screen mode, it gives you more real estate to write your code.
Like I said, the Visual Studio core team, they’ve made a lot of enhancements in the IDE, things that make your coding experience more productive and a lot more fun.
|