Editing an arbitrary XML file in
Let's say I have a structure like this:
<a> <b>...</b> </a>
Let's say the cursor is at the
I'm looking for one shortcut that brings the cursor directly from
</a>, and back if called again.
Search before you ask
This question requests one-way jump and gets an answer:
C-M-n to jump forward,
C-u -1 C-M-n to jump backwards -- Emacs, nxhtml how to highlight or jump to the closing html tag? - Stack Overflow.
But this is inconvenient because to jump back one has to:
- position the cursor exactly at end of closing tag, and
- use a long and convoluted key shortcut
C-u -1 C-M-n.
There's room for more convenience: one shortcut to do both directions.
How to do that?
If this does not already exists, I'd like to it. I'm a seasoned developer in a number of languages and environments but not proficient enough in emacs-lisp to make my own solution. Still, it might be easy enough to do for an emacs-lisp wizard.
Technically, one function with this behavior would do the trick:
- when cursor is on an opening tag, jump forwards (call
- when cursor is on a closing tag, jump backwards (call
- bonus points if, when cursor is anywhere between
>(not only just before
nxml-forward-elementrequires), the function still works
- bonus points if, when cursor is anywhere inside text or whatever, then jump backwards to opening tag.