Community
    • Login

    A way to detect bracket pairings in a macro?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 607 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alt KahA Offline
      Alt Kah
      last edited by

      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?

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @Alt Kah
        last edited by

        @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.

        1. Move the cursor to the [ or ] for the brace pair you are interested in
        2. Macro > Start Recording
        3. Search > Select All Between Matching Braces (default shortcut: Ctrl+Alt+B)
        4. Edit > Line Operations > Join Lines (default shortcut: Ctrl+J)
        5. Macro > Stop Recording
        6. Macro > Save Current Recorded Macro to Join Matching Braces or whatever you want to call it, and assign a keyboard shortcut to your liking
        Alt KahA 1 Reply Last reply Reply Quote 3
        • Alt KahA Offline
          Alt Kah @PeterJones
          last edited by

          @PeterJones Thanks! I had no idea there was a “Select All Between Matching Braces” but that will do the trick!

          1 Reply Last reply Reply Quote 1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors