Sublime Forum

Multiple Selection Scroller - advice needed

#1

Hi,

Please can I have some advice about a plugin I’ve written.

The plugin is called Multiple Selection Scroller and it allows users to scroll through their current multiple selections. It has the following capabilities:

Scroll to selection commands - center chosen selection on the middle line:

  1. Scroll to previous selection
    *] Scroll to next selection

  2. Scroll to first selection

  3. Scroll to last selection

Clear to selection commands - clear all selections leaving a single cursor at:

  1. Clear to first selection

  2. Clear to last selection

  3. Clear to selection on, or nearest to, the middle line
    /*:m]

Each of the ‘scroll to’ and ‘clear to’ commands require a key assignment. Here’s what I am currently using:

Note: The **** and ] keys are already used for line indenting and code folding, using them for multi-selection scrolling and clearing in various key combinations seems both convenient and appropriate.

Linux/Windows keymapping
------------------------

Description                                    Arg          Value       Keys
--------------------------------------------------------------------------------------
Scroll to previous selection (backwards)       scroll_to    previous    alt+
Scroll to next selection (forwards)            scroll_to    next        alt+]
Scroll to first selection                      scroll_to    first       alt+k,  alt+
Scroll to last selection                       scroll_to    last        alt+k,  alt+]
--------------------------------------------------------------------------------------
Clear to first selection                       clear_to     first       ctrl+k, ctrl+
Clear to last selection                        clear_to     last        ctrl+k, ctrl+]
Clear to selection (on/nearest) middle line    clear_to     middle      ctrl+k, 
                                                                 (No modifier for '')
--------------------------------------------------------------------------------------

With 7 key commands I am worried that it is over complicated. I could easily provide 4 commands in the .sublime-keymap files by keeping only:

  • Scroll to previous selection

  • Scroll to next selection

  • Clear to last selection

  • Clear to selection on, or nearest to, the middle line

Users could add the rest of the functionality if they want and I could provide a sample keys file to help those inclined to do so. But Sublime Texters are used to remembering keys and the whole design philosophy of the editor is that it is quickest to perform tasks with the keyboard. I guess it is a decision based on whether functionality is more important than ease of use.

I’d like to hear your thoughts on the matter please.

ALSO…

Ideas from OS X users about what keys to use for OS X would be helpful. I know the Option/Alt key is a no-go according to the ST help pages because Option+ inserts non-ascii characters. I’ve never really used OS X so am hesitant to decide on keys without advice on the matter.

Many thanks all.

0 Likes

#2

Don’t provide default keybindings, it will always conflict with existing ones for some users.

Give an example of keybindings either in readme:
packagecontrol.io/packages/FindCursor
Or with an Example.sublime-keymap:
github.com/colinta/SublimeMoveText
And let the users add them to their own .sublime-keymap.

The plugin looks like a good idea.
Some plugins already have some of the feature you propose (like FindCursor), but having all these related features in a single plugin is nice.

0 Likes

#3

Thanks bizoo. Yes, I think you’re right, that simplifies things for me too.

Mine is quite different from FindCursor and MultiEditUtils which are indeed in the same ballpark as Multiple Selection Scroller.

Through repeated pressing of the keys, Multiple Selection Scroller allows each selection to be placed on the middle line of the visible region - one at a time. The other plugins just give each full page containing selections one at a time. Crucially Multiple Selection Scroller also allows you to clear all the selections leaving the cursor at the ‘current’ one, the one on, or nearest to, the middle line. This means you can hit the ‘next/previous’ keys repeatedly until you reach the selection you want and then hit the ‘clear to middle line’ keys and you can start editing at a single cursor on the selection you wanted - without having to use the mouse. There’s no plugin available that can do that AFAIK or could find. It was my desire for this feature that led me to write the plugin.

I’ll post to this thread and to announcements when the plugin is available, but it is finished and working fine in ST v.2 and v.3. I just need to finish the readme, push it up to GitHub, and submit.

Cheers.

0 Likes

#4

You could also do something like choosy_single_selection: github.com/Veedrac/Sublime-Extras
You use it with esc and shift+esc. It’s amazing. It doesn’t center the view but that’s a one-line fix.

0 Likes

#5

Pull request submitted: github.com/Veedrac/Sublime-Extras/pull/2 Thanks for the idea!

0 Likes