Bite my bytes

What I learn by day I blog at night - A blog from Microsoft Consultant working from Ljubljana, Slovenia

  Home :: Contact :: Syndication  
  999 Posts :: 7691 Comments :: 235 Trackbacks


Most popular posts
in last 180 days


My Projects



Copyright © by David Vidmar
Contact me!
LinkedIn Profile

I don't feel so good lately. I have all signs of pneumonia but doctors say I don't have it. They say I should rest for 10 days but I cracked after 3 and went back to work. Time will tell if that was a mistake. Unfortunately, right now it looks like it might be. But that's not the point of this post!

In those 3 days I was at home I connected via VPN to my companies network and I tried to be useful.

I learned following things:

  • there is no way I could go back and use Visual Studio .Net on one monitor. Lucky I fixed that some time ago.
  • I'm addicted to DSWatch  
  • I'm addicted to VSFileFinder

I would also recommend this plugins:

  • CodeSmith (we use it to generate stored procedures and some other code)
  • UnleashIT (I use it to deploy new versions of TVvSPOREDnik)

And while we are at it, check out this macro. I call it Poor Man's Bracket Matching (at least until VS2005):

1Sub PoorMansBracketMathing()
3  Dim Matchable As String = ")}]""'"
5  Dim objTextDoc As TextDocument
6  Dim objEditPt As EditPoint
8  objTextDoc = DTE.ActiveDocument.Object("TextDocument")
9  objEditPt = objTextDoc.StartPoint.CreateEditPoint
11  Dim sel As TextSelection = DTE.ActiveDocument.Selection
12  Dim c As String
14  sel.CharLeft(True)
15  If Matchable.IndexOf(sel.Text) = 0 Then
16    c = sel.Text
17    sel.Delete()
18    DTE.ActiveDocument.Selection.Text = c
19  Else
20    sel.CharRight(False)
21    sel.CharRight(True)
22    If Matchable.IndexOf(sel.Text) = 0 Then
23      c = sel.Text
24      sel.Delete()
25      DTE.ActiveDocument.Selection.Text = c
26    Else
27      sel.CharLeft(False)
28    End If
29  End If
31End Sub

I usually assign it to CTRL + 9 key combination. Now, go to your source and put caret before or after any bracket. Press CTRL + 9. Matching bracket should appear bold for a second or two, just as it does when you first write it. As with all macros it will be rather slow when you run it for the first time, so don't dump it right away.

And it also helps if you set brace matching color to something bright, like red. Go to Tools / Options / Environment / Font and Color / Display Items: Brace Matching and set it's foreground color.

Posted on Saturday, December 04, 2004 11:16 PM | Filed under: Developement |


# Poor Man's Bracket Matching Macro 12/6/2004 11:02 PM Powertoys WebLog

# re: Working from home and plugins 12/7/2004 12:39 AM Jason Coyne
Why not just use ctrl-] ?

# re: Working from home and plugins 12/7/2004 10:55 AM David
Simply because there is no [ key on Slovenian keyboard layout.

# Powertoys blog linked me 12/11/2004 5:38 PM

# re: Cool Tools Every .Net Developer should be aware of 12/16/2004 10:26 AM ISerializable

# re: Working from home and plugins 12/21/2004 11:01 PM Samir
I'm interested, how do I implement this Macro of yours, corectly. What I did, was copy&paste code directly into VB.Net 2003 Macro Editor, named Macro1 (everything I left deafult, no renameing). I also found in MSDN, how to bind shortcut key with macro. So far so good.
But, macro isn't woring! I don't know, what is wrong, but it's not producing any desired result. And, yes, I did changed background color of brackets in "Option" menu.

# re: Working from home and plugins 12/22/2004 8:46 AM David
Here are few ideas what could you try:
- Do you see a spinning cassette icon in your lower right corner?
- Do you get any errors?
- Try running your macro directly, not from your shortcut.
- Is your caret position before or after a bracket of any kind? That's when macro actually produces anything.

Let me know the results!

# re: Working from home and plugins 12/26/2004 12:21 AM Samir
Well, I have tried:
- I do see spinning cassete icon in right lower corner
- no errors
- I tried running without shortcut
- I tried before and after opening bracket (that is: "{" ). The macro produces notihng.

I belive, that I'm doing something wrong. I must admit, that I have no experience with macro's in VS.Net.
The enviroment, that I was trying out was: VS.Net 2003 Enter. Architect, under .Net 1.1 SP1. (maybe I don't have right enviroment)

# re: Working from home and plugins 1/3/2005 6:44 PM David
now I'm lost. Can you debug the macro and see for yourself what is it trying to do? The code is rather simple, so I hope you can find the error. Ands let me know, please!

# re: Working from home and plugins 1/3/2005 6:45 PM David
No, the environment is just perfect.

I'm lost. Can you debug the macro and see for yourself what is it trying to do? The code is rather simple, so I hope you can find the error. And please let me know if you do, so I can fix the code!

# re: Working from home and plugins 1/25/2005 3:33 PM Brad Smith
This macro is designed for you to have your cursor on the *closing* bracket, and hitting Ctrl-9 highlights the matching *opening* bracket.
If you want it the other way around, change "Matchable" to "({[""'"

I'm not much of a macro programmer, so I'm not sure how to make this one macro work both ways at once. In the short term, I'll make a copy and assign it to a different key (Ctrl-0 perhaps).


# re: Working from home and plugins 1/26/2005 12:52 PM David
I didn't try, but probably if you list opening and closing it will work both ways.

# re: Working from home and plugins 5/2/2005 12:50 AM Steve Stover
I had to change both occurrences of:

If Matchable.IndexOf(sel.Text) = 0 Then


If Matchable.IndexOf(sel.Text) > -1 Then

Otherwise it will only match on parenthesis. I also couldn't get it to work with single quote or double quote, so I finally changed:

Dim Matchable As String = ")}]""'"


Dim Matchable As String = ")}]>({[<"

It will match any of those chars correctly, with the exception that it does not work in a comment line... not sure why that is!

# re: Working from home and plugins 5/5/2005 10:07 PM David
Steve, tnx for your input!

Comments have been closed on this topic.