In NetBeans, is there a keyboard shortcut for moving between HTML tags?
Asked Answered
S

2

12

When editing an HTML file, if the cursor is on an opening tag, the matching tag is highlighted in the editor. I would like to be able to map a key combination like alt+ (or something) to go to the closing tag. I looked for an existing action like this in tools->options->keymap, but did not find one, so I decided to try to create a macro for it. I have found that I can do it in multiple steps like this: ctrl+/ (fold code), , ctrl+* (unfold code). I recorded a macro of this, and it produced this code:

collapse-fold-tree caret-forward expand-fold-tree

Unfortunately, when I run the macro, the cursor stays in the same place, rather than ending up at the end of the closing tag like it does when I do the steps manually. I have successfully created a macro that moves from the closing tag to the opening tag with:

collapse-fold-tree expand-fold-tree

but I cannot get the forward one working. I am also having a bad feeling that I just overlooked the action in the keymap settings and am now trying to reinvent that wheel. Is this an action that is already there? And if not, does anyone know how I might get the macro to work?

Sarena answered 8/10, 2014 at 16:15 Comment(0)
R
18

There is an existing action in the keymap for this. It is called "Insertion Point to Matching Brace". The shortcut is ctrl + [ or command +[ in Mac.

Rotgut answered 8/10, 2014 at 16:29 Comment(2)
Great, thanks! I missed it because I wasn't thinking of them as braces, but I suppose if the editor can do code folding with them, then it does.Station
default keymap was not a good one for keyboards where ' [ ' is already a two keys symbol, anyway thanks for pointing out the name.Discrimination
F
1

There is also shortcut Ctrl + Shift + [, which selects content inside this tag.

Fiorenza answered 14/1, 2017 at 13:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.