#region’s in Visual Studio

Tuesday, December 10, 2013 Labels:

I really don’t mind regions, when used correctly (ie: sparsely). The rest of the time, however, I want to rip them all out of any code I look at. I used to use some cool macros to automatically expand all regions, but since Microsoft killed macros in Visual Studio 2013..

So, for Visual Studio 2013, I settled on automatically expanding regions when a file is opened. That way people can organize their code all they want and I don’t have to deal with it.. 8^)

The extension is called 'I Hate #Regions'.

Sadly, it will only install on Visual Studio 2010 and 2012. So, open up the .vsix file into your favorite archive tool and add edit the extension.vsixmanifest file. Insert the following snippet at the end of the Vsix/Identifier/SupportedProducts section.

   <VisualStudio Version="12.0">
     <Edition>Ultimate</Edition>
     <Edition>Premium</Edition>
     <Edition>Pro</Edition>
   </VisualStudio>

That’s it. You can download the I Hate #Regions extension from the Visual Studio Gallery.

I miss macros in Visual Studio 2012

Wednesday, January 23, 2013 Labels:

I just thought I'd share with everyone how frustrating it is to not be able to create a simple Macro in Visual Studio 2012. I know I can create an extension and it is extremely easy to do compared to previous releases.. But seriously..

I want to add a two line macro. I don’t want to create a whole project and fifty lines of code to accomplish the same thing..

Customize how search results are displayed

Wednesday, September 23, 2009 Labels: ,

I created a simple utility that can customize the Visual Studio Find Results output. I think using it should be pretty self-explanatory..

VSFindResultsEditor

I wanted something new to do this morning, what can I say!?

Download it here!

 

You can also check out Sara Ford’s blog for all the glorious details about customizing the Visual Studio Find Results output:

http://blogs.msdn.com/saraford/archive/2008/11/24/did-you-know-you-can-customize-how-search-results-are-displayed-in-the-find-results-window-363.aspx

Excellent Visual Studio tips roundup by Sara Ford

http://blogs.msdn.com/saraford/archive/2009/09/09/teched-australia-25-visual-studio-2008-ide-tips.aspx

 

The ones I found most useful (or didn’t already know) include:

Prevent copying blank lines with Ctrl+C

Look in Tools - Options - Text Editor - All Languages - General. Unchecking 'Apply Cut or Copy commands to blank lines when there is no selection' prevents copying a blank line into the clipboard.  How did I ever miss this checkbox!?

 

Incremental Search

This allows me to jump to the next match as I type it out. I LOVE it!!

   1. Press Ctrl+I
   2. Start typing the text you are searching for.  note: you'll see the cursor jump to the first match, highlighting the current search string.
   3. Press Ctrl+I again to jump to the next occurrence of the search string
   4. (advanced tip) Press Ctrl+Shift+I to search backwards
   5. To stop searching, press ESC

You’ll note that it is case-sensitive, unfortunately. I’ll have to look for a way to change that..

 

And, my total favorite is..

Customize how search results are displayed

This is one of the most irritating things ever about Visual Studio. The Find Results window is almost always filled with only the paths of the found files, instead of the line details. I always have to scroll to the right to see the details. Here is the direct link to the article, bypassing the roundup.

http://blogs.msdn.com/saraford/archive/2008/11/24/did-you-know-you-can-customize-how-search-results-are-displayed-in-the-find-results-window-363.aspx

Simple Visual Studio 2005 regular expression to swap variable assignments

Tuesday, July 21, 2009 Labels: , ,
Here is a simple regular expression to use in Visual Studio 2005 to swap the variable/object and assignment.
Find What: mySettings.{.+} = {.+};
Replace With: \2 = mySettings.\1;

Collapse folders and projects in Visual Studio

Thursday, July 16, 2009 Labels: ,

I consider the PowerCommands for Visual Studio 2008 invaluable. And, the collapse all feature is certainly one of my most used features. However, if a solution folder is already collapsed, the projects underneath are skipped.

So, I found a great macro for collapsing all solution folders and their projects, regardless of whether or not the parent solution folder(s) are open or closed.

Visual Studio 2005 Collapse All Macro

(yes, it works for Visual Studio 2008, what I primarily use)

 

For convenience, here is the macro source code:

    Sub CollapseAll()

' Get the the Solution Explorer tree
Dim solutionExplorer As UIHierarchy
solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()

' Check if there is any open solution
If (solutionExplorer.UIHierarchyItems.Count = 0) Then
Return
End If

' Get the top node (the name of the solution)
Dim rootNode As UIHierarchyItem = solutionExplorer.UIHierarchyItems.Item(1)
rootNode.DTE.SuppressUI = True

' Collapse each project node
Collapse(rootNode, solutionExplorer)

' Select the solution node, or else when you click
' on the solution window
' scrollbar, it will synchronize the open document
' with the tree and pop
' out the corresponding node which is probably not what you want.

rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
rootNode.DTE.SuppressUI = False

End Sub

Private Sub Collapse(ByVal item As UIHierarchyItem, ByRef solutionExplorer As UIHierarchy)

For Each innerItem As UIHierarchyItem In item.UIHierarchyItems
If innerItem.UIHierarchyItems.Count > 0 Then

' Re-cursive call
Collapse(innerItem, solutionExplorer)

' Collapse
If innerItem.UIHierarchyItems.Expanded Then
innerItem.UIHierarchyItems.Expanded = False
If innerItem.UIHierarchyItems.Expanded = True Then
' Bug in VS 2005
innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
solutionExplorer.DoDefaultAction()
End If
End If

End If
Next

End Sub

PowerCommands for Visual Studio 2008

Friday, October 3, 2008 Labels: ,
PowerCommands for Visual Studio 2008 is definitely one of the best plug-ins available for Visual Studio..
Includes things like:
  • Undo closed window

  • Collapse all projects

  • Copy path

  • Email CodeSnippet

  • Insert GUID from right-click menu

  • Copy and paste project references!

  • Open containing folder

  • Open command prompt

  • Unload project

  • Sort using statements / also removes un-used ones

  • And more..

  • Integrating TortoiseSVN with Visual Studio

    Thursday, September 11, 2008 Labels: ,
    Going back to using a file explorer separately for managing RCS, after using TFS built into Visual Studio has been a little irritating. That's not because I prefer TFS, because I don't. In fact, I hope I never have to go back to TFS again - at least until it doesn't crash continually and take minutes to perform actions that should take only seconds. And, of course TFS would have to actually perform the actions I request of it too. (But that's another post.)

    Nonetheless I've quickly become tired of switching between Total Commander and Visual Studio just to do updates and commits. I was about to resurrect my old CVS batch files again when I found an excellent set of scripts to enable TortoiseSVN from within Visual Studio.

    http://garrys-brain.blogspot.com/2007/07/tortoisesvn-and-visual-studio.html

    I have not tried all of the features yet, only the basics. But those have worked without any problems at all.

    Visual Studio File Comparison Settings

    Wednesday, March 7, 2007 Labels: , , ,
    .. In other words, how to set Beyond Compare as your file comparison tool in VSTS.

    I finally got tired of the default comparison tool in Visual Studio 2005 Team Edition and went poking around to find out how to set Beyond Compare to the default instead. The default utility (WinDiff, I think?) is extremely irritating after having used BC for so many years now.

    So, on the Tools | Options dialog, click on Source Control, then Visual Studio Team Foundation Server. Now, click on the "Configure User Tools..." button. Take a look at this screen shot:



    The important things to notice are the Extension and Arguments settings. The Extension specifies which files this viewer configuration will be applied to. While the Arguments are specific to the viewer application itself, in this case Beyond Compare. You can change the extension (for instance, to .cs) to apply that configuration to only those file types.

    Compare settings:

    Extension: .*
    Operation: Compare
    Command: C:\Program Files\Beyond Compare 2\BC2.exe
    Arguments: %1 %2 /title1=%6 /title2=%7

    Merge settings:

    Extension: .*
    Operation: Merge
    Command: C:\Program Files\Beyond Compare 2\BC2.exe
    Arguments: %1 %2 /savetarget=%4 /title1=%6 /title2=%7


    (Disclaimer: I have no ties whatsoever to Scooter Software, the makers of Beyond Compare.)

    Visual Studio clipboard ring and other keyboard shortcuts

    Tuesday, February 13, 2007 Labels: , ,

    Visualstudiohacks.com is always my first choice for getting the low-down on Visual Studio. On their site I found a great shortcut key to cycle through the VS clipboard ring. In doing so, I remembered that VS actually had a clipboard ring, too. I remember being excited that they were adding one, but I must've forgotten about it. It's excellent. I found it here: http://www.visualstudiohacks.com/navtricks.

    CLIPBOARD RING

    Ctrl + Shift + V

    Cycle through items copied to clipboard

    The clipboard ring's a terrific tool for doing mass edits. Move a number of items into the clipboard ring via any Copy or Cut command, then cycle through those items as you're pasting away.

    Older Posts