Multi selection and multi edit



  • Here is my entire solution (copy from this Github Issue) with NppExec which gives Notepad++ all the multi editing functionality from VSCode. The only difference is that there are two different shortcuts each for addNext and for skip.

    addNext (Ctrl-D):

    NPP_CONSOLE 0
    sci_sendmsg 2690  // SCI_TARGETWHOLEDOCUMENT
    sci_sendmsg SCI_SETSEARCHFLAGS 0
    sci_sendmsg 2688  // SCI_MULTIPLESELECTADDNEXT
    

    multiSelect_D

    addNextWholeWord (Shift-Ctrl-D):

    NPP_CONSOLE 0
    sci_sendmsg 2690  // SCI_TARGETWHOLEDOCUMENT
    sci_sendmsg SCI_SETSEARCHFLAGS SCFIND_WHOLEWORD
    sci_sendmsg 2688  // SCI_MULTIPLESELECTADDNEXT
    

    multiSelect_DW

    addEach (Shift-Ctrl-L):

    NPP_CONSOLE 0
    sci_sendmsg 2690  // SCI_TARGETWHOLEDOCUMENT
    sci_sendmsg SCI_GETSELECTIONEMPTY
    if $(MSG_RESULT) == 1 then
      sci_sendmsg SCI_SETSEARCHFLAGS SCFIND_WHOLEWORD
    else
      sci_sendmsg SCI_SETSEARCHFLAGS 0
    endif
    sci_sendmsg 2689  // SCI_MULTIPLESELECTADDEACH
    sci_sendmsg 2689  // SCI_MULTIPLESELECTADDEACH
    

    multiSelect_EACH

    undoAddNext (Ctrl-U):

    NPP_CONSOLE 0
    sci_sendmsg SCI_GETSELECTIONS
    set n ~ $(MSG_RESULT) - 1
    sci_sendmsg SCI_DROPSELECTIONN $(n)
    

    multiSelect_DU

    skip (Alt-Ctrl-D):

    NPP_CONSOLE 0
    sci_sendmsg SCI_SETSEARCHFLAGS SCFIND_NONE
    sci_sendmsg 2688  // SCI_MULTIPLESELECTADDNEXT
    sci_sendmsg SCI_GETSELECTIONS
    set n ~ $(MSG_RESULT) - 2
    sci_sendmsg SCI_DROPSELECTIONN $(n)
    

    multiSelect_DS

    skipWholeWord (Alt-Shift-Ctrl-D):

    NPP_CONSOLE 0
    sci_sendmsg SCI_SETSEARCHFLAGS SCFIND_NONE
    sci_sendmsg 2688  // SCI_MULTIPLESELECTADDNEXT
    sci_sendmsg SCI_GETSELECTIONS
    set n ~ $(MSG_RESULT) - 2
    sci_sendmsg SCI_DROPSELECTIONN $(n)
    


  • Hello
    I’m new to this but I’m interested in having the functionality to select similar strings in a document and be able to do multiple editing
    how can i add this functionality to notepad ++?



  • @michaelfernandez98

    Perhaps the simplest way would be to add the NppExec plugin to your Notepad++ and used the scripts by @bitagoras directly above?



  • yes i was watching
    I already installed the NppExec script to the notepad++
    but now the problem is how do I add the scripts by @bitagoras to the notepad ++?



  • @michaelfernandez98

    It feels a bit like spoon-feeding, but…

    • Select Plugins from the N++ menus
    • Select NppExec
    • Select Execute (default key assignment is F6)
    • Paste in ONE of the short “scripts” above in the Execute… box that appears
    • Optionally (but recommended) test run it by pressing the OK button
    • Press F6 again; “script” from before was retained and shows in the box
    • Press Save… , give it a name (suggested above the “scripts” above), press OK
    • Assign a keycombo (again; suggested ones are above the “scripts” above)


  • @michaelfernandez98 said:

    but now the problem is how do I add the scripts by @bitagoras to the notepad ++?

    @Alan-Kilborn replied:


    Assign a keycombo (again; suggested ones are above the “scripts” above)

    If saving and naming a script wasn’t obvious, then assigning a keycombo is going to be less intuitive. Just saying. ;-)

    @michaelfernandez98,
    Once you have one or more scripts named and saved as Alan described, then go to Plugins > NppExec > Advanced Options. In the lower left, use the Associated Script pulldown to select the script; click Add/Modify button to add it to the list of Menu Items in the upper left; note whether or not ☑ Place in the Macros Submenu is enabled (you will need this later). Repeat as necessary for all of the above scripts. When you hit OK to apply those changes, a popup will tell you that you should restart Notepad++: save any open files, then restart Notepad++.

    After the restart, then either the Macros menu (if the checkbox was enabled) or the Plugins > NppExec submenu (if the checkbox was disabled) will list your new NppExec scripts.

    To assign a keycombo to each, go to Macros > Modify Shortcut/Delete Macro (or, equivalently, Settings > Shortcut Mapper), and go to the Plugin Commands tab. Filter by NppExec and scroll down until you see the new script names. Click on the script you want a keycombo for, hit Modify, and pick the appropriate combination of Ctrl, Alt, Shift, and the selected key. Repeat the Modify procedure for all the scripts that you want a keycombo for.



  • @PeterJones

    Thanks for filling in those details Peter!
    As I was walking thru the steps on my setup, I didn’t do that part, so I’d forgotten that it was maybe not the most obvious thing.

    Is there a way to delete scripts that just isn’t obvious to me at the moment?
    For example, during my experimentation I named my script “junk”.
    Now I want to get rid of it, but don’t see a way to in the NppExec UI.
    Or do I have to resort to hand-editing the config file for the plugin?



  • @Alan-Kilborn said in Multi selection and multi edit:

    Now I want to get rid of it, but don’t see a way to in the NppExec UI.

    No obvious way, that’s for sure.

    The … > Advanced Options > Delete button removes it from the menu, but not from the saved scripts.

    Oh, right, there it is. F6, select junk, counter-intuitively hit Save…, then click the Delete button.



  • I could already install the plugin and assign the keycombo to it
    thanks @PeterJones @Alan-Kilborn
    They were very helpful



  • sorry if my english is bad
    I speak Spanish


Log in to reply