• Login
Community
  • Login

Multi-cursor editing

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
53 Posts 8 Posters 8.3k 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.
  • A
    Alan Kilborn @Ekopalypse
    last edited by Mar 28, 2020, 7:49 PM

    @Ekopalypse said in Multi-cursor editing:

    If I understand this correctly, then one, non-plugin way would be,
    to press and hold the CTRL button and click with the mouse on the
    respective places.

    True, but I get the feeling we are talking about hundreds of such places, potentially, which makes that problematic.

    E 1 Reply Last reply Mar 28, 2020, 7:57 PM Reply Quote 2
    • E
      Ekopalypse @Alan Kilborn
      last edited by Mar 28, 2020, 7:57 PM

      @Alan-Kilborn
      I assume so too.
      I do have a little PS script for selecting all same words

      from Npp import editor
      first_line = editor.getFirstVisibleLine()
      editor.setTarget(0, editor.getTextLength())
      editor.multipleSelectAddEach()
      editor.rotateSelection()
      editor.setFirstVisibleLine(first_line)
      
      1 Reply Last reply Reply Quote 2
      • E
        Ekopalypse
        last edited by Mar 28, 2020, 8:02 PM

        In case someone is trying this.
        If no word is selected the first execution would select the current word
        and the next execution all others.

        A 1 Reply Last reply Mar 28, 2020, 8:22 PM Reply Quote 0
        • A
          Alan Kilborn @Ekopalypse
          last edited by Mar 28, 2020, 8:22 PM

          @Ekopalypse

          Yes, this (or a variant which included a search) would get all of the carets in the correct place, but from there the OP’s desire is to be able to move all of the carets in junction to a constants offset from that point, and which point insertion/deletion would commence. At least this is what I gather from watching the OP’s video. And if I try something like that after running your script, all but one of the carets is removed as soon as I do the first cursor movement operation. I expected this.

          But I also respect the OP’s desire for something like this to be possible.

          1 Reply Last reply Reply Quote 1
          • A
            astrosofista
            last edited by Mar 28, 2020, 9:11 PM

            @Alan-Kilborn said in Multi-cursor editing:

            Yes, this (or a variant which included a search) would get all of the carets in the correct place, but from there the OP’s desire is to be able to move all of the carets in junction to a constants offset from that point, and which point insertion/deletion would commence. At least this is what I gather from watching the OP’s video. And if I try something like that after running your script, all but one of the carets is removed as soon as I do the first cursor movement operation. I expected this.

            Hi @Alan-Kilborn, @Ekopalypse, All:

            As I understand, Ekopalypse’s script in conjunction with the BetterMultiSelection plugin provide an interesting approach if not an actual solution to OP’s request.

            Take a look to how I can resolve the sample that Op posted before in this thread:

            giphy

            If needed, I can post the commands used to move the caret in the above embedded gif.

            E 1 Reply Last reply Mar 28, 2020, 10:07 PM Reply Quote 4
            • E
              Ekopalypse @astrosofista
              last edited by Mar 28, 2020, 10:07 PM

              @Alan-Kilborn, @astrosofista

              I watched the youtube video and it looks like you can do this
              with my script.
              You do get multiple selection and those will move when using the arrow keys.
              What do I miss??

              A 1 Reply Last reply Mar 28, 2020, 10:14 PM Reply Quote 0
              • A
                astrosofista @Ekopalypse
                last edited by Mar 28, 2020, 10:14 PM

                @Ekopalypse said in Multi-cursor editing:

                You do get multiple selection and those will move when using the arrow keys.
                What do I miss??

                @Ekopalypse

                You need to check the Multi-Selection option in Preferences and install the BetterMultiSelection plugin.

                E 1 Reply Last reply Mar 28, 2020, 10:15 PM Reply Quote 1
                • E
                  Ekopalypse @astrosofista
                  last edited by Mar 28, 2020, 10:15 PM

                  @astrosofista

                  thx, but I can already do what your gif shows without having BetterMultiSelection installed just by using my script.

                  A A 2 Replies Last reply Mar 28, 2020, 10:28 PM Reply Quote 1
                  • A
                    Alan Kilborn @Ekopalypse
                    last edited by Mar 28, 2020, 10:28 PM

                    @Ekopalypse

                    You do get multiple selection and those will move when using the arrow keys.

                    Well, I’ve never had much luck with doing that in a “real” way. A real way would be a real problem I’m working on.

                    BTW, I like futzing around with Notepad++ and its peculiarities, but it gets frustrating fast when you are trying to do something “real” and you run into Notepad++'s bugs. :-)

                    1 Reply Last reply Reply Quote 0
                    • E
                      Ekopalypse
                      last edited by Mar 28, 2020, 10:29 PM

                      this is how it looks like on my PC

                      1 Reply Last reply Reply Quote 3
                      • A
                        astrosofista @Ekopalypse
                        last edited by Mar 28, 2020, 10:59 PM

                        @Ekopalypse said in Multi-cursor editing:

                        thx, but I can already do what your gif shows without having BetterMultiSelection installed just by using my script.

                        @Ekopalypse

                        You are right. I disabled the plugin and your script does all the work and OP should pay close attention to it.

                        Anyway I still believe that the conjuntion of both the plugin and your script creates a better tool. The plugin works nice with contiguous selections, which it can create by draging, and your script extend its capabilities to make distant selections. I thank you for it.

                        By the way, have you plans to make the plugin able to search for partial words? At first glance looks like a nice addition.

                        Disclaimer: I am not related in any way with the mentioned plugin, just a happy user.

                        E 1 Reply Last reply Mar 28, 2020, 11:05 PM Reply Quote 2
                        • E
                          Ekopalypse @astrosofista
                          last edited by Mar 28, 2020, 11:05 PM

                          @astrosofista said in Multi-cursor editing:

                          Anyway I still believe that the conjuntion of both the plugin and your script creates a better tool.

                          Can be the case absolutely, @dail does a great job with all of his plugins. :-)

                          By the way, have you plans to make the plugin able to search for partial words? At first glance looks like a nice addition.

                          Just select the part of the word you are interest in and it should respect it already. This is a scintilla feature not really my work.

                          D A 2 Replies Last reply Mar 28, 2020, 11:08 PM Reply Quote 3
                          • D
                            dail @Ekopalypse
                            last edited by Mar 28, 2020, 11:08 PM

                            @Ekopalypse I use BetterMultiSelection in conjunction with LuaScript to select multiple instances and then edit them simultaneously…works quite nicely.

                            E M 2 Replies Last reply Mar 28, 2020, 11:10 PM Reply Quote 2
                            • E
                              Ekopalypse @dail
                              last edited by Mar 28, 2020, 11:10 PM

                              @dail

                              I have no doubt that this works great. :-)

                              1 Reply Last reply Reply Quote 1
                              • A
                                astrosofista @Ekopalypse
                                last edited by Mar 28, 2020, 11:48 PM

                                @Ekopalypse said in Multi-cursor editing:

                                Just select the part of the word you are interest in and it should respect it already. This is a scintilla feature not really my work.

                                Yes, it works fine… almost all the time. In one of my tests Notepad++ ceased to respond and have to quit it via the taskbar.

                                Better stop for today.

                                E 1 Reply Last reply Mar 30, 2020, 11:19 AM Reply Quote 2
                                • G
                                  guy038
                                  last edited by guy038 Mar 29, 2020, 9:17 PM Mar 29, 2020, 9:05 PM

                                  Hello, @czmaniak, @alan-kilobrn, @peterjones, @ekopalypse, @astrosofista,

                                  In that discussion, I suppose that the Multi-Editing option is enabled, in >Settings > Preferences... > Editing and that the BetterMultiSelection and PythonScript plugins are both installed, in your N++ configuration !


                                  It may be worth to note that, by default, in Notepad++, the multiple cursors editing feature behave differently from the column mode editing and that it is identical only if you install and enable the Better MultiSelection plugin of @dail !

                                  For instance, assuming the five lines, below, the BetterMultiSelection not enabled and the Python script not used :

                                  12 56498><717 5123 131
                                  21 78483><000 0456 235
                                  16 89410><575 5156 464
                                  97 89411><056 6045 454
                                  01 25822><644 8970 544
                                  

                                  If you create a zero-length column selection, through these five lines, between the > and < chars, you’re able to
                                  type in some chars, even tabulations and/or spaces and you may delete few chars, with the backspace or the Delete key.

                                  However, as soon as you want to use, for instance, the right arrow key or the Ctrl + Left shortcut, the Home or End key and even the Enter key, these commands do not act for all the lines of the column selection


                                  Now, click between the > and < chars of the first line. Then, holding down a Ctrl key, click, at the same location, for line 2 to 5. The screen seems similar to before but, this time, we get, I would say, something like a 5 one-line column selection ( instead a 1 five-line column selection ) !

                                  Therefore, the use of the arrow keys, shortcuts involving arrow keys, the the Home, End key and Enter key correctly act as expected ;-))

                                  The good news is that IF you enable the BetterMultiselection @Dail’s plugin, from within N++, you can, use this enhanced behaviour, too, when creating a classical column selection ;-))


                                  Obviously, the @ekopalypse’s python script does not create a column selection but, indeed, places individual cursors on every line, containing a specific word. This explains why if we use the @ekopalypse’s python script, below, we do not need the BetterMultiSeelection, in conjunction !

                                  from Npp import editor
                                  first_line = editor.getFirstVisibleLine()
                                  editor.setTarget(0, editor.getTextLength())
                                  editor.multipleSelectAddEach()
                                  editor.rotateSelection()
                                  editor.setFirstVisibleLine(first_line)
                                  

                                  Of course, this script solution seems more flexible, because it places all the cursors at the end of a specific selected word, so, not necessarily at the same column, in each line !


                                  Now, and a bit off-topic, I would like some information from Python guru’s people ;-))

                                  In order to realize this post, I decided to install, manually, on my portable N++ v7.8.5 release, the last V1.5.3 version of the PythonScript plugin, from :

                                  https://github.com/bruderstein/PythonScript/releases

                                  • First, I did not know to choose between the PythonScript_Full_1.5.3.0.zip and the PythonScript_Full_1.5.3.0_PluginAdmin.zip archives ! After downloading the two archives, I just realized that they were strictly identical and, also, verified, with WinMerge, that their contents were the same !? So what ?

                                  • Then I created, as usual, a PythonScript sub-folder, in the Plugins folder

                                  • Opening the archive PythonScript_Full_1.5.3.0.zip, I noticed that the two dll Python27.dll and PythonScript were at the same level. So, I supposed that, from now on, the Python27.dll file wasn’t anymore along with the Notepad++.exe file

                                  • Therefore, I just extracted all the contents of the archive in the PythonScript sub-folder, that I just created

                                  • However, during N++ start-up, I got the message, in French :

                                  “This application could not start because python27.dll cannot be found. …”

                                  • Luckily, putting back the Python27.dll library, along with Notepad++.exe, everything is back to normal ;-)) And the consultation of the v1.5.3 documentation works just fine, too, from its new location !

                                  Best Regards,

                                  guy038

                                  A 2 Replies Last reply Mar 30, 2020, 12:10 AM Reply Quote 2
                                  • A
                                    Alan Kilborn @guy038
                                    last edited by Alan Kilborn Mar 30, 2020, 12:11 AM Mar 30, 2020, 12:10 AM

                                    @guy038 said in Multi-cursor editing:

                                    PythonScript_Full_1.5.3.0.zip and the PythonScript_Full_1.5.3.0_PluginAdmin.zip … they were strictly identical

                                    I also confirm this.
                                    No idea as to the “why” of it.

                                    “This application could not start because python27.dll cannot be found. …”

                                    This part I could NOT duplicate.
                                    For me it worked just fine with python27.dll in the PythonScript subfolder under Plugins.

                                    af070d32-a41b-46a6-b7f6-26ffac5cb85d-image.png

                                    1 Reply Last reply Reply Quote 1
                                    • A
                                      Alan Kilborn @guy038
                                      last edited by Mar 30, 2020, 12:24 AM

                                      @guy038 said in Multi-cursor editing:

                                      So I tried the following with no BetterMultiselection plugin, nor any Pythonscript influence. I’m interested in what you think about it.

                                      I started with this text:

                                      12 56498><717 5123 131
                                      21 78483><000 0456 235
                                      16 89410><575 5156 464
                                      97 89411><056 6045 454
                                      01 25822><644 8970 544
                                      
                                      123
                                      456789
                                      
                                      12 56498><717 5123 131
                                      21 78483><000 0456 235
                                      16 89410><575 5156 464
                                      97 89411><056 6045 454
                                      01 25822><644 8970 544
                                      

                                      and created “a 5 one-line column selection” like you did on the first five lines. Thus the most-recent (i.e., the “main” selection caret) was on the 5th line.

                                      My goal in this testing was to use the down arrow (and only that key) to move my “selection carets” so that they were in the same spot in the lower grouping of five lines as they were in the top set of five lines.

                                      I found I could not do it.

                                      What I obtained was four carets in column 1 and one caret (the original “main” selection one) in between the >< on the last line of the file.

                                      To be fair to N++, I did the same test in the Scintilla demo editor, with the same result.

                                      Maybe my expectation in this scenario is unrealistic?

                                      1 Reply Last reply Reply Quote 1
                                      • E
                                        Ekopalypse @astrosofista
                                        last edited by Mar 30, 2020, 11:19 AM

                                        @astrosofista said in Multi-cursor editing:

                                        … almost all the time

                                        Ooopppss - did not happen to me yet.
                                        Is it possible that a very, very large amount of data had to be selected?
                                        I have done a small performance/stress test using this script to generate the test data.

                                        editor.appendText('This is a teest to see if it works\r\n'*100000)

                                        It took about 1 minute, on my PC, until all 100_000 instances were selected.
                                        For a test with 1000 instances, which in my opinion is still not
                                        a real world test - I mean, who has 1000 instances of the same word
                                        in their source code? - it actually selected it immediately.

                                        @guy038 , @Alan-Kilborn

                                        I ASSUME one of it, guess which one, is for the plugin admin,
                                        maybe a naming thing?? But of course, if both are the same then the
                                        non-plugin-admin version could have been deleted.

                                        Python27 should be loadable from within plugin directory.
                                        There was a change in npp source which allows plugins now to find
                                        their needed dlls within its directory.

                                        A 1 Reply Last reply Mar 30, 2020, 4:27 PM Reply Quote 2
                                        • G
                                          guy038
                                          last edited by guy038 Mar 30, 2020, 2:11 PM Mar 30, 2020, 12:07 PM

                                          Hello, @czmaniak, @alan-kilborn, @peterjones, @ekopalypse, @astrosofista,

                                          Regarding the Python problem, I deleted my Python install and re-installed the plugin with, unfortunately, the same result. My python27.dll library has version 2.7.17150.1013 and contains 2,649,600 bytes. But, never minds : it should be related to my old Win-XP laptop !!


                                          Now, Alan, assuming the text,below :

                                          123
                                          456789
                                          
                                          12 56498><717 5123 131
                                          21 78483><000 0456 235
                                          16 89410><575 5156 464
                                          97 89411><056 6045 454
                                          01 25822><644 8970 544
                                          
                                          123
                                          456789
                                          
                                          12 56498><717 5123 131
                                          21 78483><000 0456 235
                                          16 89410><575 5156 464
                                          97 89411><056 6045 454
                                          01 25822><644 8970 544
                                          
                                          123
                                          456789
                                          

                                          I did your test, without any plugin, involved :

                                          • I placed a caret, between the > and < chars inside the first block, so 5 ones, using the Ctrl key

                                          • Then, hitting 9 times on the Down arrow, only, I obtained exactly what you got !

                                          • Now, cancel any null selection

                                          • Create a normal column selection, between the > and < chars of the first block

                                          • Then, hitting 9 times on the Down arrow, only, anunique cursor was present on the 5th line of the second block


                                          • Now, enable the BetterMultiSelection plugin

                                          • Place a caret, between the > and < chars inside the first block, so 5 ones, using the Ctrl key

                                          • If you hit 9 times on the Down arrow, only, this time, the 5 carets are correctly located, between the > and < chars of the second block of five lines :-))

                                          • Cancel any null selection

                                          • Create a normal column selection, between the > and < chars of the first block

                                          • If you hit 9 times on the Down arrow, only, again, the 5 carets are correctly located, between the > and < chars of the second block of five lines :-))

                                          So, the @dail’s BetterMultiSelection plugin is definitively a must and should be installed and enabled every time ;-))


                                          IMPORTANT : To cancel any complicated number of selections, resulting of the use of the BetterMultiSelection plugin, simply hit the ESC key !

                                          Cheers,

                                          guy038

                                          E A 2 Replies Last reply Mar 30, 2020, 12:21 PM Reply Quote 1
                                          20 out of 53
                                          • First post
                                            20/53
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors