A way to detect bracket pairings in a macro?
-
I would like a way to do the following:
Position on the first of some sort of structure, like so
structure header [ Item 1; Item 2 is a Structure [ Item 2a; Item 2b; ]; One last item; ]; #end of the structure
And what I want to be able to do is, select all the lines of text and Ctrl-J them into a single line, so I would end up with this:
structure header [ Item 1; Item 2 is a Structure [ Item 2a; Item 2b; ]; One last item; ]; #end of the structure
Leveraging the logic N++ uses to detect the end bracket when positioned on the beginning. This would get rolled into a macro that handles each line after the joining.
Any idea how to accomplish this?
-
@Alt-Kah said in A way to detect bracket pairings in a macro?:
Any idea how to accomplish this?
Fortunately, there are recordable menu commands that do the various steps you want.
- Move the cursor to the
[
or]
for the brace pair you are interested in - Macro > Start Recording
- Search > Select All Between Matching Braces (default shortcut:
Ctrl+Alt+B
) - Edit > Line Operations > Join Lines (default shortcut:
Ctrl+J
) - Macro > Stop Recording
- Macro > Save Current Recorded Macro to
Join Matching Braces
or whatever you want to call it, and assign a keyboard shortcut to your liking
- Move the cursor to the
-
@PeterJones Thanks! I had no idea there was a “Select All Between Matching Braces” but that will do the trick!