Jumping from end of block to its beginning, or highlighting the block

Frequently I have the following code structure:
        ...
      end
    end
  end
end

and I want to start editing between two of those -- but the right two! So I want to be able to match an 'end' to its beginning -- whether by jumping to the beginning, or by highlighting the block. I know that IDEA knows where blocks start and end, since I can fold them. But folding seems to be too jarring. I'd like the equivalent of Vim's "%" command instead, which jumps from an opening parenthesis or bracket to the closing. Except with code blocks. Does this feature exist? Thanks.

2
5 comments
Navigate to Next Method Alt+Down Navigate to the next method declaration in the active editor tab.
Navigate to Previous Method Alt+Up Navigate to the previous method declaration in the active editor tab.
Navigate to Opening Brace Ctrl+Open Bracket Navigate to the start of the current code block.
Navigate to Closing Brace Ctrl+Close Bracket Navigate to the end of the current code block.


Ctrl+W will progressively select code "segments", eventually to the brace level, then method, then class: Ctrl+Shift+W will deselect.

2

I am using the Vim keymap on a Mac, and I've not been able to find any of these. I open Preferences, Keymap, then try searching for some keywords like "segment" or "brace", but come up emptyhanded. How can I find these actions in my keymap?

0

Keymap > Editor Actions > Move Caret to Code Block End/Start
Keymap > Main Menu > Navigate >previous/Next Method

As a tip, to find a (default) key mapping when a word search does not work (in this case you were unaware the key words were Code Block)  do the following:

  1. temporarily switch back to the default mapping
  2. click the "Find actions by shortcut" button to the right of the search box (To clear anything you've entered, use the clear filtering button )
  3. type the key sequence
  4. make note of the location and/or key words
  5. change back to your mapping, navigate to the action and make the change
0

Mark, where did you get the names "Navigate to Opening Brace", and "Navigate to Closing Brace" from? These aren't in my Mac's PHPStorm Preferences Keymap search; the first two do come up thankfully as sub-options.

Also it's weird that Keymap is showing a bunch of results without the searched-for word when I search for `block`:

Can you explain its reasoning there?

1

Mark, where did you get the names "Navigate to Opening Brace", and "Navigate to Closing Brace" from?

It's been 8-1/2 years since I made the post, but I believe those were the terms used in the user guide. As noted in my followup post, the name of the actions in the keymap were Keymap > Editor Actions > Move Caret to Code Block End

Also it's weird that Keymap is showing a bunch of results without the searched-for word when I search for `block`:

That's because the work 'block' appears in the actions' description. For example, for "Expand Recursively" the description is "Expand block at caret recursively" See below screenshot. which shows the description in the bottom left of the status bar. So that's why the search is picking them up. Which in some cases is useful to find the desired action.

1

Please sign in to leave a comment.