Welcome to MSDN Blogs Sign in | Join | Help

John's Blog

MS PM OK?
C# Express: My favorite IDE tricks

Having had reason to play with C# Express for the past few months, I’ve learned a few tricks that speed up my programming and just make life a lot more enjoyable. Maybe “tricks” is the wrong word – these features are kind of obvious once you know them, and most have been around in previous versions of Visual Studio – but until recently I’ve just not known about them. I hope you find them as useful as I do.

 

Switch Between Source and Design Views

 

I don’t want to count the number of times I switch between Code and Design views when working on a project. Let’s just say “a lot”. I used to click on the little tabs above the view window. In larger projects it became difficult to remember which source tab I wanted – eventually there were so many tabs that I had to scroll left and right through the list just to find the right one.

 

Now however, I just press F7 or Shift-F7 to switch from Code to Design views. Bliss.

 

Windows Splitting and Multiple Views

 

I like my high-resolution LCD display, mostly because I can display a lot of stuff at once. I also like how how C# Express lets me see even more by allowing me to create a new window, or split the current view, from the top two items in the Windows menu.

 

The new window option creates a new view of the same source code. This can be very useful when working in longer projects, when you often need to jump from one location to another. Setting up each in its own tabbed view makes that switching a lot quicker – especially when I get to tip on window navigation.

 

If you would like to see two views on your source code at once, then use the Split option to divide the source window in two. Again, this can speed things up when working in two different locations.

 

New Tab Groups

 

Have you ever wanted to see the Design view and Code view at the same time? All you need to do is select New Horizontal Tab Group or New Vertical Tab Group. This creates an entirely new view window, complete with tabs. Each view can be split (allowing you to create some crazy views) but also toggled between Code and Design. This makes it possible to see your Windows Form and the Code behind at simultaneously.

 

Cycling Through Open Windows

 

With all these windows and views open, how do you keep track? Easy – press CTRL & Tab, and in the center of the screen a box will appear listing all the open windows. Just select the one you want, and it will become the foreground active window.

 

Reset

 

Have you torn off windows, left them floating around the screen, created too many views, and generally just got everything in a mess? The Reset Window Layout menu option under Window is your friend.

 

Bookmarks

 

I love bookmarks. Bookmarks are great when you are working on a longer project spread over different forms and source files. When you are working on an important section, press CTRL, B and T to create a bookmark: a blue blob will appear in the margin. Press that combination again to delete the bookmark. T stands for “Toggle”, ok?

 

Now you can press CTRL, B and P to jump to the previous bookmark, and CTRL, B and N to jump to the next bookmark.

 

Over to you

 

Have you any tricks or favorite features you’d like to share? Add a comment below.

Posted: Wednesday, June 30, 2004 8:33 AM by johnkenn
Filed under:

Comments

Nikolai said:

Comment Selections

When I don't need some code, but I don't want to just delete it, I comment it out.
When I need to comment out a large chunck of code, I select it all, and press Ctrl+K+C. To uncomment, I select commented code, then press Ctrl+K+U.
# June 30, 2004 10:34 AM

Austin said:

I had the same problem switching between Source and Design view. I however did not like having to remember to use F7 or Shift-F7.

Therefore I wrote this macro to toggle Source and Design windows. This works in Web and Win Forms. I assigned my keyboard shortcut to Alt-Space. Maybe you will find it usefull too.

Imports EnvDTE
Imports System.Diagnostics
Imports System.ComponentModel.Design

Public Module ToggleWindows
Sub ToggleDesignAndCodeWindows()
If (((TypeOf DTE.ActiveWindow.Object Is IDesignerHost) OrElse (TypeOf DTE.ActiveWindow.Object Is HTMLWindow)) AndAlso (DTE.Commands.Item("View.ViewCode").IsAvailable)) Then
DTE.ExecuteCommand("View.ViewCode")
Else
Dim projItem As ProjectItem
Dim activeDocFullName As String = DTE.ActiveDocument.FullName
Dim formFullName As String = activeDocFullName.Substring(0, activeDocFullName.LastIndexOf("."))

projItem = DTE.Solution.FindProjectItem(formFullName)

If (Not projItem Is Nothing) Then
Try
projItem.Open(Constants.vsViewKindPrimary).Activate()
Catch e As System.NullReferenceException
' Do nothing. Needed for asmx and ascx pages.
End Try
Else
If DTE.Commands.Item("View.ViewDesigner").IsAvailable Then
DTE.ExecuteCommand("View.ViewDesigner")
Else
Beep()
End If
End If
End If
End Sub
End Module
# June 30, 2004 12:22 PM

Austin said:

I forgot to mention that I have only used this macro in VS 2002 and 2003. I have not tried it in 2005 yet.
# June 30, 2004 12:24 PM

John said:

This sounds a great macro - unfortunately Macro support isn't present in Express. :-/
# June 30, 2004 1:33 PM

Dan Fernandez's Blog said:

# July 6, 2004 10:56 PM

Djof said:

Those with 5 buttoms mice can use the forward/backward buttons just like in a browser.
# July 17, 2004 2:15 PM

Di .NET e di altre amenit said:

# August 27, 2004 4:17 AM
New Comments to this post are disabled
Page view tracker