![]() |
Monday, June 23, 2003 |
Source: Frans Bouma's blog; 6/23/2003; 7:31:11 AM Yesterday I was playing around with VS.NET and discovered that I didn't use any macro's at all. So I opened up the macro IDE and looked at the examples. It's pretty easy stuff. So I wrote my first macro. It is a set of macro's actually which create #region ... #endregion sections. Two pre-defined ones for members and properties and a generic one which pops up an input box for the region name. Bind them to a hotkey and you're set. I'm pretty sure the code can be more efficient, it's my first attempt to write a macro that manipulates an active document in the IDE, so if I'm doing things in an inefficient way, that's the reason ;) The initial macro I wanted to create was a create property macro which also created the related member variable in the region I've defined for that. Unfortunately, the IDE's code elements collection doesn't contain region sections, so this would be a hard thing to do efficiently. The code is pasted below. Copy it into a new macro project and bind the macro's to hotkeys. Have fun :). Oh, you can of course modify the macro to work with VB.NET, but be aware of the fact that VB.NET doesn't support regions in a lot of places in your code. Usage: select some lines in your code, call one of the macro's, and it's a region, baby :) You can also apply the macro's on empty selections.
[Frans Bouma's blog]8:02:59 AM ![]() |