Welcome to AddressOf.com Sign in | Join | Help

VB 2005 Snippet Annoyance - A solution...

With VB's snippet feature, every time you add a new snippet the coloring stays around until you close the file and re-open it.  This can quickly lead to a lot of visual clutter while your developing if you use snippets a lot.  And why shouldn't you leverage such a feature?

Well, during the beta I asked about whether this would be resolved in some manner and it was a bit late in the schedule.  So I set out to figure out a possible work around.  The work around consists of a simple macro that will save your current cursor location, save/close the file, open the file and return the cursor to it's current location.  You can configure the macro to work as a tool bar button and/or a keyboard combination. 

Here's what I'm referring to (visually):

Here's the macro.

Sub ReloadFile()


  ' Make a note of the current file.

  Dim file As String = DTE.ActiveDocument.FullName


  ' Make a note of the current cursor position.

  Dim ep As EditPoint = CType(DTE.ActiveDocument.Selection, TextSelection).ActivePoint.CreateEditPoint


  ' Save the current file.



  ' Close the current file.



  ' Open the current file.



  ' Move cursor to the previously saved position.

  CType(DTE.ActiveDocument.Selection, TextSelection).MoveToLineAndOffset(ep.Line, ep.LineCharOffset)


End Sub




Note:  For a step by step walk through on creating and consuming macros, see here.

Published Tuesday, November 1, 2005 6:38 PM by CorySmith
Filed under: ,


No Comments

Anonymous comments are disabled