Wednesday, June 30, 2010
Code Snippet Shortcut
Note to self: to quickly insert a code snippet in Visual Studio, just type the name of the snippet and hit the tab key. This is much easier than hunting through the multi-nested context menus to find the snippet. ;)
Wednesday, March 24, 2010
Markup/Code Behind Switcher
I can't live without this macro. I literally use it hundreds of times a day. The code below, once added to a macro in Visual Studio and assigned a hot key, allows me to quickly switch from markup to code behind, or vice versa, regardless of the current file I am viewing.
Sub SwitchToMarkup()
Dim fileName As String
Dim docName As String
Dim docFullName As String
docName = DTE.ActiveWindow.Document.Name.ToLower()
docFullName = DTE.ActiveWindow.Document.FullName.ToLower()
If (docName.EndsWith(".cs")) Then
fileName = docFullName.Replace(".cs", "")
ElseIf (docName.EndsWith(".aspx")) Then
fileName = docFullName.Replace(".aspx", ".aspx.cs")
ElseIf (docName.EndsWith(".ascx")) Then
fileName = docFullName.Replace(".ascx", ".ascx.cs")
ElseIf (docName.EndsWith(".master")) Then
fileName = docFullName.Replace(".master", ".master.cs")
End If
If (fileName.Length() > 0) Then
If System.IO.File.Exists(fileName) Then
DTE.ItemOperations.OpenFile(fileName)
End If
End If
End Sub
Wednesday, October 21, 2009
Long Lost Friend Found: SelectCurrentWord
In versions previous to Visual Studio 2008, there was a keystroke that I used all the time: CTRL + W. This selected the current word that your cursor was on in the code. However, once I upgraded to Visual Studio 2008, they remapped that keystroke. After a lot of Google searching, I finally stumbled upon the new keystroke: SHIFT + CTRL + W!
I feel like I've found my long, lost friend.
I feel like I've found my long, lost friend.
Tuesday, April 7, 2009
IE8 Compatibility View Icon Proposal
Wednesday, March 11, 2009
Cleaning Visual Studio Recent Projects
If you have ever changed the path of a Visual Studio project, you have probably discovered that a broken link remains in the "Recent Projects" section on the start page. If you click the broken link, Visual Studio informs you that the project is missing and asks if you would like to remove it from the list. This works fine for one project, but if you have moved several projects, the Recent Projects list becomes polluted with broken links.
I wanted to find a way to clean up that list, so that only valid projects were displayed. Fortunately, there is a way--by using the good, ol' registry.
The project links are stored under this path in the registry: (the 8.0 part may be different depending on your version of Visual Studio):
HKCU\Software\Microsoft\VisualStudio\8.0\ProjectMRUList
If you navigate to this path in regedit, you can manage the list. I ended up just deleting all of the entries to give me a clean slate. After doing that, when I loaded up Visual Studio, the Recent Projects list was cleared. I was then able to open each project manually, which repopulates the list with the correct project paths. You could also modify the paths for each entry, but I was too lazy for that. ;)
I wanted to find a way to clean up that list, so that only valid projects were displayed. Fortunately, there is a way--by using the good, ol' registry.
The project links are stored under this path in the registry: (the 8.0 part may be different depending on your version of Visual Studio):
HKCU\Software\Microsoft\VisualStudio\8.0\ProjectMRUList
If you navigate to this path in regedit, you can manage the list. I ended up just deleting all of the entries to give me a clean slate. After doing that, when I loaded up Visual Studio, the Recent Projects list was cleared. I was then able to open each project manually, which repopulates the list with the correct project paths. You could also modify the paths for each entry, but I was too lazy for that. ;)
Tuesday, February 3, 2009
MeasureIt Firefox Plug-in
One thing I love about Firefox is the broad range of available developer-friendly plug-ins. The other day, a co-worker of mine told me about MeasureIt, a handy plug-in that allows you to measure sizes of things on a web page, similar in concept to the IE Developer Toolbar's ruler.
Once installed, the plug-in displays at the bottom of your browser:

When you click on it, the current page you are viewing fades and you are given a cross-hair cursor. You can then click and drag a rectangle to measure heights and widths right on the page.
Once installed, the plug-in displays at the bottom of your browser:

When you click on it, the current page you are viewing fades and you are given a cross-hair cursor. You can then click and drag a rectangle to measure heights and widths right on the page.
Tuesday, December 16, 2008
Typedef in C#
Note to self (and to anyone else interested):
A typedef in C++, such as
typedef short SmallNumber; // C++
can be translated in C# as
using SmallNumber = System.Int16; // C#
This example is trivial, but it's very handy to be able to create an alias for long type names, especially when you start getting into generics.
A typedef in C++, such as
typedef short SmallNumber; // C++
can be translated in C# as
using SmallNumber = System.Int16; // C#
This example is trivial, but it's very handy to be able to create an alias for long type names, especially when you start getting into generics.
Subscribe to:
Posts (Atom)

