Community
    • Login

    Add line break in paste after multi-editing

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 3 Posters 1.6k Views
    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.
    • Spiros DoikasS
      Spiros Doikas
      last edited by

      Currently, if one selects multiple strings and then pastes, they are pasted in one long string. It would be more practical if each item was separated by a line break or even better if one could have a setting for their preferred delimiter.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Spiros Doikas
        last edited by

        @spiros-doikas

        see “FAQ: Feature Request”

        Spiros DoikasS 1 Reply Last reply Reply Quote 1
        • Spiros DoikasS
          Spiros Doikas @PeterJones
          last edited by

          https://github.com/notepad-plus-plus/notepad-plus-plus/issues/11781

          Alan KilbornA 1 Reply Last reply Reply Quote 2
          • Alan KilbornA
            Alan Kilborn @Spiros Doikas
            last edited by

            @spiros-doikas said in Add line break in paste after multi-editing:

            if one selects multiple strings and then pastes, they are pasted in one long string

            Don’t you really mean?:

            “if one selects multiple strings and then copies, then pastes that data somewhere else, they are pasted as one long string”

            Such behavior is arguably best left to scripting. Here’s a PythonScript that I call MultiSelectCopyAddDelimiters.py that implements the desired functionality:

            # -*- coding: utf-8 -*-
            
            #-------------------------------------------------------------------------------
            
            class MSCAD(object):
            
                def __init__(self):
                    preferred_delimiter = '\r\n'
                    if editor.getSelections() == 1 or editor.selectionIsRectangle(): return  # not our purview
                    sel_text_list = []
                    for n in range(editor.getSelections()):
                        (s, e) = (editor.getSelectionNStart(n), editor.getSelectionNEnd(n))
                        t = editor.getTextRange(s, e)
                        sel_text_list.append(t)
                    editor.copyText(preferred_delimiter.join(sel_text_list) + '\r\n')
            
            #-------------------------------------------------------------------------------
            
            if __name__ == '__main__': MSCAD()
            
            1 Reply Last reply Reply Quote 2
            • Spiros DoikasS
              Spiros Doikas
              last edited by

              Hi thanks!

              Well, in my opinion this is very basic functionality making paste after multi-copy usable in common scenarios (compare similar functionality in MS Word for example).

              Not sure how to run the script. I tried multi copy first, then running the script via Plugins > Python Script > the actual script but I had no output.

              Alan KilbornA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @Spiros Doikas
                last edited by

                @spiros-doikas said in Add line break in paste after multi-editing:

                Not sure how to run the script. I tried multi copy first, then running the script via Plugins > Python Script > the actual script but I had no output.

                It sounds like you figured out what you needed to do (mostly), but I should have directed you HERE anyway (sorry).

                To use the script you need to have multiple-selections active first, then run the script, then do a paste somewhere (I thought this was obvious?).

                Spiros DoikasS 1 Reply Last reply Reply Quote 1
                • Spiros DoikasS
                  Spiros Doikas @Alan Kilborn
                  last edited by

                  To use the script you need to have multiple-selections active first, then run the script, then do a paste somewhere (I thought this was obvious?).

                  This is what I did:

                  1. multiple-selections active
                  2. Make multi-selections and press Ctrl+C
                  3. run the script
                  4. do a paste somewhere
                  Alan KilbornA 1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @Spiros Doikas
                    last edited by Alan Kilborn

                    @spiros-doikas

                    I’m really confused but maybe you are one of those confusing persons we get here occasionally. :-) I’m not even sure from your most-recent posting if a) you can’t get it to work or b) you got it to work and you are just sharing what you did as part of a victory lap. I’ll assume a)…

                    If you have “multiple selections active” in step 1 why do you need to “make multi-selections” in step 2?

                    There is no need to press Ctrl+c in your step 2; the script does the copy.

                    Let me show how it should go:

                    1. Make multiple selections:
                      0fe46eda-9dfc-45b6-bb9b-3d6e96458f05-image.png

                    2. Run the script (because you want to copy, with delimiters between the individual items, the currently multi-selected text).

                    3. Paste somewhere to obtain:
                      20e07f9b-217e-4180-b0ed-fd573a408573-image.png

                    Is this not clear?
                    Anyone? Anyone?

                    Spiros DoikasS 1 Reply Last reply Reply Quote 0
                    • Spiros DoikasS
                      Spiros Doikas @Alan Kilborn
                      last edited by Spiros Doikas

                      @alan-kilborn Thank you! I did try the way you described it. But it would not paste the multi-selection items (instead it pastes what was previously in the clipboard).
                      Please see below

                      https://ibb.co/gSRGXpH

                      Alan KilbornA 1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Spiros Doikas
                        last edited by

                        @spiros-doikas

                        Well, I guess at this point we have to wait for someone else to try it, and weigh in on how it went for them. :-(

                        Spiros DoikasS PeterJonesP 2 Replies Last reply Reply Quote 0
                        • Spiros DoikasS
                          Spiros Doikas @Alan Kilborn
                          last edited by

                          @alan-kilborn Your code may be just fine, and thank you again for that, it could be anything as we have different environments… I tested of course other scripts from the same folder and they do produce results.

                          1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Alan Kilborn
                            last edited by

                            @alan-kilborn said in Add line break in paste after multi-editing:

                            wait for someone else to try it, and weigh in on how it went for them

                            I installed the script, selected old text and verified it was in the clipboard by pasting. Then I selected two or three disjoint sections in multi-select mode, ran the script, and then pasted, and it pasted each section of the new multi-section data with a newline between, so worked exactly as I believe it was described.

                            @Spiros-Doikas , you should look at Plugins > Python Script > Show Console after running the script, and see if it is giving you an error message.

                            1 Reply Last reply Reply Quote 2
                            • First post
                              Last post
                            The Community of users of the Notepad++ text editor.
                            Powered by NodeBB | Contributors