Keyboard shortcut for going to beginning of switch block?

I'm working with a lot of files that have huge `switch` statements, some of these files have multiple `switch` statements that are big (yes, I know it's poorly-coded and these should probably be class objects), and often it's hard to see the context. I want a keyboard shortcut for "go to beginning of switch block or statement", but the keyboard shortcut to go to the beginning of a block (or opening brace) will only do that for the current sub-block in a `case` block (like if the caret is in a function or if/else or for loop etc)...

Did I miss something? Maybe if there isn't or can't be a keyboard shortcut for this, what other way can I try to help better contextualize the case block other than text search or scrolling?

3 comments
Comment actions Permalink

but the keyboard shortcut to go to the beginning of a block (or opening brace) will only do that for the current sub-block in a case block (like if the caret is in a function or if/else or for loop etc)...

I can't reproduce that, for me in the following snippet, both Ctrl+[ (Move Caret to Code Block Start) and Ctrl+Shift+M (Move Caret to Matching Brace) place the caret at the beginning of the switch block.

<?php

switch ($i) {
    case 0:
        echo "i equals 0";
        break;
    case 1:
        echo "i equals 1";<caret here>
        break;
    case 2:
        echo "i equals 2";
        break;
}
?>

What am I missing?

0
Comment actions Permalink

Your `switch` block is not inside of another block.

0
Comment actions Permalink

Do you think you could create a brief code sample marking where the caret is and where you want it to go? It'd help understand the request greatly. Thanks!

0

Please sign in to leave a comment.