Re: Match <div and </div>
Benno Schulenberg <[email protected]> Mon, 23 Jan 2023 16:17:31 +0100
| Newsgroups | gmane.editors.nano.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Sébastien,
Op 23-01-2023 om 14:18 schreef Seb:
> I am looking for a way to jump from a <div (in an HTML file) to
> the matching </div> (with other <div's inbetween) and vice versa.
>
> Is there a standard way of doing this that I have overlooked?
There is no built-in way for doing this. The 'findbracket' function
works only between single code points.
> Or, any idea how to do this?
When you add this to your .nanorc:
set matchbrackets "(<[{«﹝)>]}»﹞"
then the following key binding should work:
bind M-B "{replace}<div{enter}﹝{enter}A
{replace}</div{enter}﹞{enter}A
{findbracket}
{replace}﹞{enter}</div{enter}A
{replace}﹝{enter}<div{enter}A
{left}{right}" main
Note that I have wrapped the string for clarity. In your .nanorc
file the binding should be a single long line without any spaces
between the quotes. Note that the mini tortoise brackets are
double-width characters. Of course, you can choose any pair of
special characters that you like, as long as they will never occur
in any of your HTML documents.
(The final {left}{right} are not essential -- they serve just to
clear the "Replaced xxx occurrences" message from the status bar,
when using --quickblank or --minibar.)
Benno
OpenPGP_signature
(application/pgp-signature, 840 B) - not displayed