21

I know it's simple to do in C#, but what is the command to jump between If/End If marks in VB.Net like you can jump between braces in C#?

(C#-version of this Question: Go to Matching Brace in Visual Studio?)

Community
  • 1
  • 1
hometoast
  • 11,522
  • 5
  • 41
  • 58
  • Hans, but the IDE knows the other parts of the block, since it highlights it when selecting one of them. – hometoast Oct 26 '11 at 18:06

3 Answers3

31

If you're using Visual Studio 2010, you can use Ctrl+Shift+Up and Ctrl+Shift+Down to jump between highlighted references and keywords.

Since these are If blocks, the IDE will highlight the Then keyword as well, so just tap Up/Down twice in rapid succession. Up/down wraps, so if you really want to save a keypress, hit the key in the "wrong" direction to get where you want.

xav
  • 5,452
  • 7
  • 48
  • 57
Jason Malinowski
  • 18,148
  • 1
  • 38
  • 55
0

As I saw else marked when my caret stood at an if (in PHP code),
https://google.com/search?q=jump+between+if+and+else+in+vscode brought me here,
and patching together various hints led me to the following commands,
bound in Visual Studio Code aka VSCode

@ Command Palette (++P @ macOS)
Go to Previous Symbol Highlight
Go to Next Symbol Highlight

Reverse engineered default F7 / +F7 @ keybindings.json:

    {
        "key": "f7",
        "command": "editor.action.wordHighlight.next",
        "when": "editorTextFocus && hasWordHighlights"
    },
    {
        "key": "shift+f7",
        "command": "editor.action.wordHighlight.prev",
        "when": "editorTextFocus && hasWordHighlights"
    },

To fit the right hand over a numpad keyboard,
and having a lot of combinations bound to other commands,
my keybindings.json (syntax is .jsonc - JSON with Comments) adds:

    {
        "key": "ctrl+numpad_subtract",
        "command": "editor.action.wordHighlight.prev" // "Go to Previous Symbol Highlight"
    },
    {
        "key": "ctrl+numpad_add",
        "command": "editor.action.wordHighlight.next" // "Go to Next Symbol Highlight"
    },
vike
  • 339
  • 6
  • 10
0

I've resorted to putting the opening curly-bracket in a comment just after the THEN and a matching closing curly-bracket in a comment before the EndIf. This is a ghetto way of allowing VI to match the start/end of the block using % keystroke.

A more elegant way would be to use some sort of IDE that understands the block concept in the language you are editing. Sometimes this feature is called a "folding editor" as per http://en.wikipedia.org/wiki/Folding_editor

MarkHu
  • 1,694
  • 16
  • 29