[New Plugin] BetterMultiSelection



  • This provides better cursor movements when using multiple selections. Supported cursor movements are:

    • Left
    • Right
    • Home
    • End
    • Word Left (Ctrl+Left)
    • Word Right (Ctrl+Right)

    You can also hold down Shift to extend the selections.

    Note: This is still in early development. It has not been tested with non-US keyboard layouts. This does have some minor quirks (such as the cursor not always blinking correctly, smart-highlighting not always working, etc) that are a side effect of the implementation.

    demo

    Download (32 & 64bit): https://github.com/dail8859/BetterMultiSelection/releases
    Readme/code/github project: https://github.com/dail8859/BetterMultiSelection



  • Hi, @dail,

    After some testing on your new BetterMultiSelection plugin, it’s just a pleasure to use it, instead of the present N++ rectangular selection :-)) Indeed ! And I do think that this behaviour should be the default one, implemented in the next official N++ release !


    In addition, it also improves typing, when you use multi-editing ( several simultaneous carets )

    To test it :

    • First, verify that Dail’s plugin is running ( Plugin > BetterMultiSelection > Enable )

    • If necessary, set the Multi-Editing functionality ( Settings - Preferences - Editing - Multi-Editing Settings - Enable )

    • Recopy, for instance, the example text , below, in a new tab ( three identical lines, separated by two blank lines ) :

    abcdef   ghijkl   mnopqr
    
    abcdef   ghijkl   mnopqr
    
    abcdef   ghijkl   mnopqr
    
    • Place, first, the caret after the j letter of the first line

    • Then, holding down the CTRL key, place a second caret after the j letter, of the second line

    • Again, holding down the CTRL key, place a third caret after the j letter, of the third line

    And now…, just play, with any of the following keys or shortcuts :

    • Home , End, Shift + Home, Shift + End

    • Left , Right, Shift + Left, Shift + Right

    • Ctrl + Left , Ctrl + Right, Shift + Ctrl + Left, Shift + Ctrl + Right

    Quite easy, isn’t it ? Very useful plugin !!

    Best Regards,

    guy038

    P.S. :

    For people, wondering about the different steps, of the demo.gif animation, here is the solution !

    So, given the original text, with the caret, located at the beginning of word myTable :

    print myTable
    print myVar
    print myOtherVar
    

    The following ordered actions :

    • Alt + Shift + Down arrow ( x 2), to get the rectangular selection, on the three lines

    • Shift + Home key

    • Suppr key

    • Tabulation key

    • String cout

    • Space bar

    • String <<

    • Space bar

    • Shift + End key

    • Crtl + D

    • Right arrow

    • Space bar

    • Ctrl + Left arrow

    • String "

    • Ctrl + Right arrow

    • Space bar

    • Left arrow

    • String is

    • Space bar

    • String "

    • Space bar

    • String <<

    • Right arrow

    • Ctrl + Right arrow

    • String .toString();

    • Left arrow

    • Space bar

    • String <<

    • Space bar

    • String endl

    produces the final text, below, with a tabulation character, at beginning of each line :

    	cout << "myTable is " << myTable.toString() << endl;
    	cout << "myVar is " << myVar.toString() << endl;
    	cout << "myOtherVar is " << myOtherVar.toString() << endl;
    


  • @guy038

    Thanks for testing it out and glad it works well for you.

    And I do think that this behaviour should be the default one, implemented in the next official N++ release !

    If Notepad++ ever updates to Scintilla v3.6.0+ then this behavior and more is already built in to Scintilla simply by turning on the SCI_SETADDITIONALSELECTIONTYPING option.



  • Hi, dail!

    Amazing work… thank you!

    I tried Better Multi Selection with an non-US keyboard layout (in my case, Brazilian ABNT2 layout) and it seen ok with accented letters like á, ç, ê…

    But i think i find a problem with chars like $ and @…
    I posted a animated gif about a this possible problem in you extension:
    Better Multi Selection possible bug?

    More info:
    I’m using Notepad++ ver 1.3.3 (32 bits) on Windows 7 (64 bits, Brazilian Portuguese)



  • @OverlordBR

    I’m glad you are finding it useful.

    From the gif it looks like this is correct behavior. By default Notepad++ does not treat $ and @ as “word characters”. If you are able, you can verify that this is just Notepad++ behavior by placing only 1 cursor in the file on line 3 and performing the same cursor movements.



  • Oh… you are right! Notepad++ has the same behavior. :(



  • @dail

    i only saw the latest version of your plugin now (it didn’t show on Plugin Manager’s updates tab)
    but… the new feature of “press Enter to insert newlines” works great and is super useful!

    Thank you!



  • Hi! excellent one, but I will love to have multi carets selected with Shift+ALT working like the multi-carets we get with CTRL+click.

    Example: I have 200 hundred lines and I want to add some text at the end of each line. I would love to multi-select all the lines with Shift+Alt and press End to go till the end of all selected lines with the carets enabled yet (now the N++ loses those multi-carets) .

    I know I can do this doing 200 Ctrl+click, but it’s a bit time consuming.

    Another way can be to do a search and replace of the end of the line, but If I only want to do that on a little section of the file I need to do the search and replace controlled by line, clicking on replace on each line I want to do the change.



  • @E-de-Miguel said in [New Plugin] BetterMultiSelection:

    Hi! excellent one, but I will love to have multi carets selected with Shift+ALT working like the multi-carets we get with CTRL+click.

    Shift+Alt is not multi-select; it is column select, which is a different selection feature, and the END key will not work the same as multi-select.

    Another way can be to do a search and replace of the end of the line, but If I only want to do that on a little section of the file I need to do the search and replace controlled by line, clicking on replace on each line I want to do the change.

    I don’t know if you’re interested in workarounds:

    • You could temporarily copy that “little section” into a temporary document, do the search and replace, then paste it back in the real document.
    • You could temporarily add in some sort of STARTBLOCK and ENDBLOCK indicators, and develop a regex that would only work between those indicators. If you want to go this route, let us know, and one of the regex experts should likely step in and suggest an implementation.


  • @E-de-Miguel ,

    I just thought of another alternative: Make your normal selection of all 200 lines (or whatever), then in the Replace dialog, enable the In Selection checkbox. now the search/replace will only affect lines in your active selection.



  • @E-de-Miguel said in [New Plugin] BetterMultiSelection:

    Example: I have 200 hundred lines and I want to add some text at the end of each line. I would love to multi-select all the lines with Shift+Alt and press End to go till the end of all selected lines with the carets enabled yet (now the N++ loses those multi-carets) .

    I have no problem doing this (with BetterMultiSelection installed and enabled). I make a column-block on (any) parts of all the lines I want to affect – doesn’t have to be something that boxes in the entire line – and then I press the End key and blammo! – I get a bunch of carets at the end of each individual line.



  • @E-de-Miguel said in [New Plugin] BetterMultiSelection:

    Another way can be to do a search and replace of the end of the line, but If I only want to do that on a little section of the file I need to do the search and replace controlled by line, clicking on replace on each line I want to do the change.

    I don’t have any trouble doing this sort of thing, either.
    This time I don’t even use features of the Better Multiselection plugin.
    Just stream (not-column) select the lines you want to effect, and then when you run the replacement operation (presumably using the $ assertion), tick the In Selection checkbox so that the replacement only affects the pre-selected lines. Requires Replace All not Replace though.

    Regarding “clicking replace on each line” – that part doesn’t make sense, because you start out talking about getting a caret at the end of each line to add/remove some text, but now you are talking about selectively choosing which lines you’d want to modify. Which is it, all or individually…you can’t have it both ways.

    Plus if you want to make a decision on each line, just stop when you are past the point (presumably of the original block you were talking about making) where you want to affect.

    Bottom line is I see no real difficulty in achieving the goals here.



  • Hi @E-de-Miguel,

    As @Alan-Kilborn and @PeterJones told you, the BetterMultiSelection plugin works as you were wishing. If you still are not convinced, please take a look at these animations and follow the instructions to better grasp how the plugin works

    https://community.notepad-plus-plus.org/post/53667
    https://community.notepad-plus-plus.org/post/54925
    https://community.notepad-plus-plus.org/post/51906
    https://community.notepad-plus-plus.org/post/53168 (explanation)
    https://community.notepad-plus-plus.org/post/51915
    https://community.notepad-plus-plus.org/post/51786

    Take care and have fun!



  • @Alan-Kilborn said in [New Plugin] BetterMultiSelection:

    @E-de-Miguel said in [New Plugin] BetterMultiSelection:

    Example: I have 200 hundred lines and I want to add some text at the end of each line. I would love to multi-select all the lines with Shift+Alt and press End to go till the end of all selected lines with the carets enabled yet (now the N++ loses those multi-carets) .

    I have no problem doing this (with BetterMultiSelection installed and enabled). I make a column-block on (any) parts of all the lines I want to affect – doesn’t have to be something that boxes in the entire line – and then I press the End key and blammo! – I get a bunch of carets at the end of each individual line.

    @E-de-Miguel

    @Alan-Kilborn is describing the expected behavior and I also do this frequently.


Log in to reply