visual studio

Visual Studio Keyboard Tip #7 - Incremental Search

The Visual Studio editor has a very useful incremental search feature built in. Let’s try it out.

  • Create a new Windows Application project.
  • Open up the Form1.Designer.cs file in the editor.
  • CTRL + I (this activates Incremental search mode)
  • Type: “disp” (without the quotes)
  • The selection should have moved to the first match of “disp” in the file.
  • Type CTRL + I again. This moves you to the next match.
  • CTRL + SHIFT + I moves you to the previous match.
  • BACKSPACE removes the last character from the search string.
  • ESC cancels incremental search mode.

visual studio
keyboard
c#
.net

Comments (0)

Permalink

ScottGu’s ASP.NET 2.0 Tips/Tricks TechEd Talk Posted

If you develop with ASP.NET you need to subscribe to Scott Guthrie’s blog.

His blog is full of detailed and well written articles that provide invaluable insight to any ASP.NET programmer.

He just posted the PowerPoint presentation and the sample code from his TechEd talk. I would highly recommend you download and review the sample project. I know every time I download samples that Scott has posted I learn something new.

Some of the features shown:

  • app_offline.htm
  • cross page postbacks
  • maintaining scrollback position
  • default button
  • custom databinding expressions

visual studio
c#
.net

Comments (0)

Permalink

Visual Studio Keyboard Tip #6 - Find Window Command Line

There’s a great feature hidden in the Find Window Combo Box that is part of the standard Toolbar in Visual Studio.

  1. Open Visual Studio
  2. CTRL + N (Create a new file) choose “HTML Page”
  3. Position the cursor on the tag
  4. Press CTRL + /
  5. The focus should have shifted to the Find Combo Box
  6. Type >
  7. Now type E
  8. Cool! It’s a command line with built in Intellisense.
  9. Type dit.LineT
  10. The entry for Edit.LineTranspose should be selected
  11. Press enter

You’ll notice that the and tags are now transposed. Take a few minutes to look around at what commands are available in this list. You can browse the list by entering one letter at a time. For example “>a” to see all the items that begin with a.
This is a great way to quickly execute commands that aren’t mapped to convenient keyboard shortcuts.

visual studio
keyboard
programming

Comments (0)

Permalink

Team Foundation Server Project Guidance

Eric Lee’s blog post provides some guidance into how Microsoft sets up the Areas for a Team Project in Visual Studio Team System.

I know this has been a source of a little bit of confusion for TFS users, so it’s nice to see an example of how Microsoft is using the feature internally.

Thanks for the post Eric, would it be possible for you to show us an example of how you setup the Iteration tab too?

visual studio
c#
.net
tfs

Comments (0)

Permalink

MSDN Wiki!

I don’t know how long this has been available, but MSDN has a wiki!

I read about it first in Shawn Steele’s Blog. What is very cool is there are a number of Microsoft developers that are adding comments.

Here are some helpful entries I’ve found:

  • David M. Kean’s post: breaking changes to System.Uri.
  • Adam Nathan’s post: details of the Type Library Exporter.
  • Craig Skibo’s post: Visual Studio Automation object oversight.
  • Ken Cox’s post: details on encrypting connection strings in your web.config file.

There was a very minor positioning issue when using FireFox, the header for each content submission was aligned incorrectly.

Overall a very good resource that I’m going to be checking out more often.

visual studio
c#
.net

Comments (0)

Permalink

Visual Studio Keyboard Tip #5 - Code Snippets

When I first saw code snippets in the Eclipse IDE a few years ago, I thought it was a great feature. It’s nice to see it included in Visual Studio 2005.

Let’s take a quick tour.

  1. Open up visual studio, and go to any C# code editor window.
  2. Position the cursor inside a method and enter CTRL + SPACE

Code Snippet Dropdown

In the dropdown that appears, look at the icon next to the #if or #region — that icon indicates the entry is a code snippet. Ok, next step:

  1. Type for
  2. This should set the selected index of the dropdown to the entry for.
  3. While for is selected enter TAB, then TAB again.

You should see this:

For Code Snippet

The caret is positioned on the i. Type the following word - index. Then hit TAB. You should see that all instances of i are replaced with index. Pretty cool.

Even better, all code snippets are defined in an xml format that you can edit.

  1. Enter the following keys CTRL + K, CTRL + B. This should bring up the code snippet manager.
  2. Expand the Visual C# node, then select for, in the location label right between the Language dropdown and the treeview gives you the location of the xml for the code snippet.
  3. Select and copy the path, then enter CTRL + 0 (that’s not a zero), and paste it into the filename, hit enter, and now you’ll see the xml for the code snippet.

This post on the VSEditor blog provides some details on the schema used to create a code snippet file.

I hope you are enjoying this series of visual studio keyboard tips. If you have any editor/keyboard topics that you would like to see, please feel free to comment on this blog and I’ll try and create a new post covering it. Thanks for reading!

visual studio
keyboard
c#

Comments (0)

Permalink

Visual Studio Keyboard Tip #4 - Outlining

Wouldn’t it be great if you had the ability to make all the other code in the text editor disappear, so that you could just focus on the one method you are working on?

That would be really cool. Unfortunately I have no idea how to do that. But I can show you the next closest thing….outlining!

Open up Visual Studio 2005, and create a brand new Windows Application Project.
Expand the Form1.cs file in the Solution Explorer, and open up the Form1.Designer.cs file.

You’ll see there is some grey text at the bottom of the screen “Windows Form Designer generated code.” Hmm, let’s see what type of code was generated.

CTRL + M, then CTRL + P

You should see that the whole file is now visible — all outlining has been removed. Cool. Next let’s collapse the whole file down.

CTRL + M, then CTRL + O

That’s a letter O by the way. Now you should see a very clean higher level view of what’s contained in the file. Next to each region you’ll see a + that you can use to expand the region. Don’t reach for the mouse yet. Since this is a keyboard tip, we should really review the keyboard shortcut to expand and collapse a region.

Move to line 23 (CTRL + G, then enter 23). You should be on the “Windows Form Designer generated code.”

CTRL + M, then CTRL + M

That region should have expanded. Now move to line 29 (CTRL + G, then enter 29). You should now be on the InitializeComponent method.

CTRL + M, then CTRL + M

The region expands. If you enter the same keyboard combinations again, the region collapses.

One last tip. Let’s expand the whole document again.

CTRL + M, then CTRL + P

Move to line 32 (CTRL + G, then enter 32). Select the text on line 32 and 33.

CTRL + M, then CTRL + H

Pretty cool, huh? Those two selected lines have now been collapsed inside the method down to an ellipsis. This only works in C#, there is no other outlining being done in the whole file, and text is selected.

visual studio
keyboard

Comments (0)

Permalink

My new coding font for Visual Studio

Microsoft released Consolas which is now my coding font of choice. It’s very clear and easy to read.

I found that I had to increase the font size to 11 which I didn’t have to do with other fonts. Overall, it’s a great coding font.

visual studio

Comments (0)

Permalink

Visual Studio HTML Editor Navigation

If you code ASP.NET websites, you need to read Scott Guthrie’s Blog.

In this post Scott demonstrates a great feature of the HTML editor in Visual Studio. When you switch from design to source view the editor keeps the same position.

For example if you select some text that appears in the design view, then switch to source view the selection will automatically be set to the same text.

This feature can help save lots of scanning around an html file.

visual studio
keyboard

Comments (0)

Permalink

Visual Studio Keyboard Tip #3 - Formatting

To automatically format your code in Visual Studio 2005 use the following keyboard shortcuts:

Format Document: CTRL + E, then D
Format Selection: CTRL + E, then F

If you have any syntax errors in your code then the formatting features do not seem to work. So, if you are trying to use the keyboard shortcuts to format a document and it doesn’t seem to be working, then check your code.

The formatting engine is great. You are also able to customize what the format style you want to use for each language you work with. Go to the Tools menu, click Options. Select Text Editor, then the language, for example C#. Expand the node in the tree (C# in this case) and you’ll see either a Format or Formatting child node. Once you select that you’ll see the options available to you.

visual studio
keyboard

Comments (1)

Permalink