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.
Please sign in to leave a comment.
Ctrl+W will progressively select code "segments", eventually to the brace level, then method, then class: Ctrl+Shift+W will deselect.
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?
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
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.
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?
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: