25

Is there a shortcut or where I can click to find the matching tag of a markup tag and bring the focus/cursor there?

For example, <p><span></span><div></div></p>

If my cursor is on the closing </p> tag, I would like to IDEA to bring me to the opening </p> tag.

Glide
  • 20,235
  • 26
  • 86
  • 135

3 Answers3

41
  • Ctrl+[ goes to the opening tag
  • Ctrl+] goes to the closing tag

The action is called Move caret to code block end/start and hotkey can be changed in Settings | Keymap.

On IntelliJ 2017 for Mac the shortcuts are:

  • Alt+Command+[ goes to the opening tag
  • Alt+Command+] goes to the closing tag
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 2
    I'm working with Freemarker files (.ftl) and it doesn't work for it. Is there a way to make it work for Freemarker files? – Glide Mar 09 '11 at 23:29
  • What language is set for these files in Settings | Template Data Languages? – CrazyCoder Mar 10 '11 at 02:10
  • Nothing was set. I tried setting it to HTML and then tried Ctrl+[ and it still didn't work – Glide Mar 10 '11 at 02:48
  • Please file an issue at http://youtrack.jetbrains.net/issues/IDEA with a small sample project attached. – CrazyCoder Mar 10 '11 at 04:56
  • @GarfieldKlon, change the shortcuts in `Settings` | `Keymap`. – CrazyCoder Dec 10 '12 at 14:46
  • @CrazyCoder any idea why it fails to work for `.html.erb` files? Works fine in pure HTML or CSS files but I'm having trouble using it in my Rails views. – dev May 24 '14 at 23:35
  • It works fine in IntelliJ 13 with a Swiss keyboard, if you remap the key to CTRL + "è/ü" and "umlaut". Because the opening/closing brakets are on these keys, but accessible with the "Alt Gr" modifier. – Pierre Henry Aug 07 '14 at 08:10
6

On IntelliJ 2016 for Mac this command seems to be:

  • Command+Shift+M goes to the matching tag / brace
Code Commander
  • 16,771
  • 8
  • 64
  • 65
3

On the Mac, I use Move caret to matching brace, Ctrl+M.

Jeremy Ross
  • 11,544
  • 3
  • 36
  • 36