T O P I C R E V I E W |
meissnersd |
Posted - Sep 26 2006 : 10:53:49 AM Hi, I love VassistX. Its great!
Ok now for my feature request... :-)
I am often moving up and down a large function. Down/up arrow it too slow, it hits too many lines. The Next scope function in VassistX is often too big a step.
I think I want Next/Previous Code Block It navigates in the Y direction in a file
A block line is any line of code that does not have white space or { } Non-block are lines with space, tabs, newline and { } char.
So if you started at line 102
line# 100 if( isX ) 101 { 102 foo(); 103 //stuff 104 // more stuff 105 } 106 else 107 { 108 bar(1); 109 bar(2); 110 bar(3); 111 } 112 112 return false;
Alt-Down arrow is Next Block three times would move the cursor You would hop to 106 else 108 bar(1) 112 return false
this is a lot faster... Prev Block would move you up to the end of the previous block of course.
|
3 L A T E S T R E P L I E S (Newest First) |
feline |
Posted - Oct 05 2006 : 1:04:40 PM very interesting i am going to have some fun studying this
it looks like these use the IDE's build in find dialog. i assume that these DTE calls and the dialog both run through the same underlying code.
does this replace the current find with your search regular expression? it should not be to hard (optimistic expression) to write the correct regular expression for an empty line, or a line full of white space, once i find the help for the IDE's regular expression syntax.
in long functions - i try to avoid them but they happen all the same, blank lines are a useful separator. |
meissnersd |
Posted - Oct 05 2006 : 12:55:59 PM Hey feline, the macro idea is a good one. Here is a simple macro that can move you one line past the next curly brace. Typically, in C++ and C# this is the next "interesting" code block. It would have to be fixed for VB
I wrotethis macro in MyMacros and mapped it to a hot key. In Tools->Customize->Keyboard map Macros.MyMacros.BlockStep.PrevStep to CTRL+UP and Macros.MyMacros.BlockStep.NextStep to CTRL+DOWN. (Note remove conflicting default keyboard mappings first! ). That scheme complements well with CRLT-left and right that moves you past a word
It does close to what I want. '------------------------------------------------------------- Option Strict Off Option Explicit Off Imports System Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics
Public Module BlockStep
Sub NextStep() DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr DTE.Find.FindWhat = "[\\{\\}]"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument DTE.Find.MatchCase = False DTE.Find.MatchWholeWord = False DTE.Find.MatchInHiddenText = True
DTE.Find.Backwards = False
DTE.Find.Action = vsFindAction.vsFindActionFind result = DTE.Find.Execute()
DTE.Windows.Item(Constants.vsWindowKindFindResults1).Close() DTE.ActiveDocument.Selection.LineDown()
End Sub
Sub PrevStep() DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr DTE.Find.FindWhat = "[\\{\\}]"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument DTE.Find.MatchCase = False DTE.Find.MatchWholeWord = False DTE.Find.MatchInHiddenText = True
DTE.Find.Backwards = True
DTE.Find.Action = vsFindAction.vsFindActionFind result = DTE.Find.Execute()
DTE.Windows.Item(Constants.vsWindowKindFindResults1).Close()
DTE.ActiveDocument.Selection.LineUp()
End Sub End Module
|
feline |
Posted - Sep 26 2006 : 5:12:10 PM i know exactly what you are after, this is a feature i use a lot in VIM
i recall mentioning this myself a long time ago, and someone saying that they could write a macro in VC6 to do this very quickly, but they did not know how to write a macro in VS2003 to do it.
i have put in a feature request, since i know just how useful this can be. however don't expect this to happen soon, if ever.
case=2726
using the find feature the IDE, set to regular expressions, the find string:
^$
matches a blank line. it might be worth trying to write a pair of macro's to do this, if you have any knowledge of the macro language in your IDE.
the other approach is to try and keep your functions fairly short. i know, easier said than done, but still valid advice. |
|
|