help-nano
[Top][All Lists]
Advanced

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

Re: Match <div and </div>


From: Seb
Subject: Re: Match <div and </div>
Date: Tue, 24 Jan 2023 06:52:26 +0100 (CET)
User-agent: Alpine 2.21 (DEB 202 2017-01-01)


Hi Benno,


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

Thank you so much! It's perfect.

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.

One detail for other readers of the list: I didn't see any "tortoise bracket" in your email. But there were question marks. I replaced them with ¤ and ª which are latin1 characters that never appear in my files.

The way you solved the problem indicates that the same technique would work for other pairs, such as <form or <p. But I don't want to assign a keystroke to each. I tried to modify the line by replacing the first "div" with "(\w+)" and the following ones with "\1", as I would in a Perl regexp. It's not working. Maybe regexps are not allowed in a key binding, or maybe I'm not writing them the right way. Could you guide me?


Best regards,
Sébastien.


reply via email to

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