IntelliJ IDEA find matching parenthesis / bracket
Solution 1
use CTRL-W to expand the selection within a bracket, use repeatedly if needed to select further out, then use the arrows.
Solution 2
You can use
Ctrl + [
andCtrl + ]
to navigate to a code block's start and end.You can also use
Ctrl + Shift + M
to navigate between the start and end of a code block.
On Mac, you can use Option + Cmd +[
and Option + Cmd + ]
, and Ctrl + M
Source: https://www.jetbrains.com/help/idea/2016.2/navigating-to-braces.html
Solution 3
CTRLSHIFTM is the Windows/Linux default shortcut for action "Move caret to matched brace". (For other environments see here and use the Shortcuts dropdown in the top right of the page.)
Or if desired, the shortcut keys can be changed as follows: Go to Settings -> Keymap -> Editor Actions, or just type the name in the search box.
Solution 4
Here's the latest and greatest as of version 2020.1
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
From the documentation
Navigate with the caret
To navigate backwards, press Ctrl+Alt+← Left. To navigate forward, press Ctrl+Alt+→→ Right.
To navigate to the last edited location, press Ctrl+Shift+Backspace.
To find the current caret location in the editor, press Ctrl+M. This action might be helpful if you do not want to scroll through a large file.
However, you can press the Up and Down arrow keys to achieve the same result.
To highlight a word at the caret you are trying to locate, select Edit | Find | Next Occurrence of the Word at Caret from the main menu.
To see on what element the caret is currently positioned, press Alt+Q.
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
To move the caret forward to the next paragraph or backward to the previous one, press Ctrl+Shift+A and search for the Move Caret Forward a Paragraph or Move Caret Backward a Paragraph action.
You can also select a text and then move the caret forward or backward to a paragraph. Press Ctrl+Shift+[ and search for the Move Caret Forward a Paragraph with Selection or Move Caret Backward a Paragraph with Selection action.
Related videos on Youtube
caponica
Updated on June 17, 2022Comments
-
caponica almost 2 years
Is there any keyboard shortcut to navigate from one parenthesis
(
to the matching one)
in IntelliJ?Or even to "jump to the next opening/closing parenthesis
(
/)
from wherever my cursor is"?And, if there's no way to do it 'natively', are there any plugins that could add this functionality quickly and easily?
EDIT: the best solution I've found is added as a comment in liango's answer below, namely to put the cursor on the first or last brace and then press
CTRL-W
twice. Not ideal, but it does the job!-
LazyOne about 10 yearsThere is no built in functionality for that, AFAIK. But you could try AceJump and emacsIDEAs plugins. What they offer is not "direct" jump .. but some advanced stuff .. which may not be suitable for you (too "advanced" -- with AceJump it's like "Ctrl+;" then ")" and then what ")" you want to jump to -- 3 keys in total).
-
caponica about 10 yearsThanks for this - I'll give AceJump a whirl and see how it goes. If anybody else has any suggestions for alternatives please do share.
-
lena about 10 yearsplease also vote for IDEA-12068
-
UserOfStackOverFlow about 2 yearsOne of the most useful questions here on this website.
-
-
caponica almost 10 yearsThat's an interesting hack to get there - thanks for sharing. (I need to find a new mapping for it, though.. CTRL-W is 'close document' in my set up)
-
caponica over 9 yearsI'm trying to get matched parentheses
()
not braces{}
:) -
caponica over 9 yearsThis is incorrect - as stated above, I'm trying to jump between (...) not {...}
-
caponica almost 9 yearsBest solution I've found: put the cursor on the first/last brace and then press CTRL-W twice.
-
kaka almost 8 yearsThis is the correct answer. It works for all types of brackets, []{}()<>. Ctrl+Shift+M
-
caponica over 7 yearsThanks - this is now the correct answer (some 2 years after the question was first asked). Although, I think it's something like
Ctrl + [
to go to nearest{
andCtrl + Shift + [
(which isCtrl + {
) to SELECT to the nearest{
-
Neerkoli over 7 years@caponica Uh yeah.. I'm sorry I've mistaken something there. You're right,
Ctrl + paranthesis
does not work. -
Sterex almost 7 yearsOn Mac, you can use
Option + Cmd +[
andOption + Cmd + ]
, andCtrl + M
. -
voddan almost 5 years@SteveChambers IJ has ~5 keymap schemes across 3 OSs. In what environment are those the default shortcut?
-
Steve Chambers almost 5 years@voddan Good point - I've modified your answer to specify the environment and provide a link for other environments.
-
Gunnar Bernstein over 4 yearsThis does not work for german keyboards. You have to reassign the key to Ctrl+8 and Ctrl+9, where the brackets sit, but require Alt Gr to be pressed.
-
Noumenon almost 3 yearsFor Mac it's
^+M
-- saved you some clicks. -
Mikko Ohtamaa over 2 yearsI also recommend
Move Cared to Code Block Start/End Code with Selection
bound to shift + option + command +[
and]
on Mac by default. Also if you do not remember keyboard shortcuts you can useshift
x2 to open the command palette, and Actions search section to look up actions by typing their name.