Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Add line break in paste after multi-editing

    Help wanted · · · – – – · · ·
    3
    12
    400
    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 Doikas
      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.

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

        @spiros-doikas

        see “FAQ: Feature Request”

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

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

          Alan Kilborn 1 Reply Last reply Reply Quote 2
          • Alan Kilborn
            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 Doikas
              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 Kilborn 1 Reply Last reply Reply Quote 0
              • Alan Kilborn
                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 Doikas 1 Reply Last reply Reply Quote 1
                • Spiros Doikas
                  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 Kilborn 1 Reply Last reply Reply Quote 0
                  • Alan Kilborn
                    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 Doikas 1 Reply Last reply Reply Quote 0
                    • Spiros Doikas
                      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 Kilborn 1 Reply Last reply Reply Quote 0
                      • Alan Kilborn
                        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 Doikas PeterJones 2 Replies Last reply Reply Quote 0
                        • Spiros Doikas
                          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
                          • PeterJones
                            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
                            Copyright © 2014 NodeBB Forums | Contributors