• Login
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.
  • S
    Spiros Doikas
    last edited by Jun 10, 2022, 6:53 PM

    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.

    P 1 Reply Last reply Jun 10, 2022, 6:54 PM Reply Quote 0
    • P
      PeterJones @Spiros Doikas
      last edited by Jun 10, 2022, 6:54 PM

      @spiros-doikas

      see “FAQ: Feature Request”

      S 1 Reply Last reply Jun 10, 2022, 7:37 PM Reply Quote 1
      • S
        Spiros Doikas @PeterJones
        last edited by Jun 10, 2022, 7:37 PM

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

        A 1 Reply Last reply Jun 10, 2022, 8:05 PM Reply Quote 2
        • A
          Alan Kilborn @Spiros Doikas
          last edited by Jun 10, 2022, 8:05 PM

          @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
          • S
            Spiros Doikas
            last edited by Jun 11, 2022, 2:05 PM

            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.

            A 1 Reply Last reply Jun 11, 2022, 4:10 PM Reply Quote 0
            • A
              Alan Kilborn @Spiros Doikas
              last edited by Jun 11, 2022, 4:10 PM

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

              S 1 Reply Last reply Jun 11, 2022, 7:40 PM Reply Quote 1
              • S
                Spiros Doikas @Alan Kilborn
                last edited by Jun 11, 2022, 7:40 PM

                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
                A 1 Reply Last reply Jun 11, 2022, 11:18 PM Reply Quote 0
                • A
                  Alan Kilborn @Spiros Doikas
                  last edited by Alan Kilborn Jun 11, 2022, 11:20 PM Jun 11, 2022, 11:18 PM

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

                  S 1 Reply Last reply Jun 12, 2022, 8:22 AM Reply Quote 0
                  • S
                    Spiros Doikas @Alan Kilborn
                    last edited by Spiros Doikas Jun 12, 2022, 8:24 AM Jun 12, 2022, 8:22 AM

                    @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

                    A 1 Reply Last reply Jun 12, 2022, 11:34 AM Reply Quote 0
                    • A
                      Alan Kilborn @Spiros Doikas
                      last edited by Jun 12, 2022, 11:34 AM

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

                      S P 2 Replies Last reply Jun 12, 2022, 3:55 PM Reply Quote 0
                      • S
                        Spiros Doikas @Alan Kilborn
                        last edited by Jun 12, 2022, 3:55 PM

                        @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
                        • P
                          PeterJones @Alan Kilborn
                          last edited by Jun 12, 2022, 8:33 PM

                          @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
                          10 out of 12
                          • First post
                            10/12
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors