help-nano
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Match <div and </div>


From: Benno Schulenberg
Subject: Re: Match <div and </div>
Date: Mon, 23 Jan 2023 16:17:31 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2


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

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]