Wednesday, December 12, 2007

Visual Studio .Net Editor Tips - Part 1

1. Custom task list tokens:

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.

2. Backward and forward navigation:

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.

3. 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.

4. Bookmarks:

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.

5. Clipboard ring:

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.

Source: MSDN blogs.

1 comment:

Anonymous said...

Re 5:

I haven't seen the clipboard ring tab in the toolbox since VS2003. It seems to have disappeared.

I quite liked this feature, the only way I know how to access it now is using Crtl+Shift+V.

Are certain it still exists?

If so please share with us how it's accessed.