Sublime Forum

Free Select Mode

#1

I love the way Sublime handles selections, it’s incredibly powerful. I’ve always wished it were possible to have the same selective agility with the keyboard as with the mouse, though. I’m not looking for a full vim clone/command mode, just some way to emulate the ctrl+click to add another carat without the mouse. Is this something presently possible I’ve overlooked, or maybe a request for Sublime X?

0 Likes

#2

You have Ctrl+Alt+Up and Ctrl+Alt+Down

If you already have a selection, Ctrl+Shift+K and Ctrl+Shift+L can be useful as well

0 Likes

#3

I am familiar with those (pre-X, still waiting for up/down in X), but they are not even similar to ctrl+click. I’m talking about free cursor placement.

0 Likes

#4

But if you press the arrow keys, the carets will move (which is a good thing)

So how would this work?

0 Likes

#5

I think the idea is that you could press some button that makes the arrows move a “potential insertion point” (for lack of a better term) around instead of all the current insertion points.
Windows Explorer has something similar to this idea. If you hold the ctrl key and press up and down, it moves a dashed box from item to item. If (still holding control) you press space, it toggles the selection for that item.

0 Likes

#6

Exactly – the idea is to have some way for the carat to not move (at my command), so that I can insert multiple carats. You just -cannot- do this without the mouse

Once I’ve got my selection points, then I want the carats to move about.

0 Likes

#7

I added alt+f3 to my bag of multi-select tricks a while ago, and it accomplishes most of what you are trying to get at. Just select a phrase, press alt+f3, and then all copies in the current buffer are selected.

I would like it if this could be done from the Find dialog, which would also allow regular expressions for selecting.

0 Likes

#8

The find panel has a find all button (though the incremental find dialog does not).
In either case, you can map the command “findAll”–I’ve mapped it to ctrl+shift+a–in order to select all copies in the current buffer.

0 Likes

#9

I’m pretty sure there’s no way to do that currently in either Sublime or X.

But if you provide a good use case (what key to press, how it’d work, etc), maybe Jon will have a look at it; it could be useful.

I currently use the bookmarks to achieve something similar: move your caret around, press Ctrl+F2 to set a caret/selection bookmark, and when you’re done, click Alt-F2 to select all the bookmarks.

0 Likes

#10

As mentioned above, you can go a long way with Alt+F3.

There are a few commands that exist that you may find interesting, but they’re aren’t bound to anything by default:

markSelection: Pushes the current selection onto the selection stack
prevInSelectionHistory: Changes the current selection to the previous one on the stack
nextInSelectionHistory: Changes the current selection to the next one on the stack
clearSelectionHistory
mergeSelection: Combines the current and previous entries on the selection stack
conflateSelection: Combines the current and previous entries on the stack by selecting everything in between them

I personally haven’t ever found these to be terribly useful, which is why they aren’t bound to anything, but I’d be happy if someone did find a use for them.

0 Likes

#11

Sublimator’s multiselect plugin (I’ve never used it) actually seems to do something similar:
bitbucket.org/sublimator/multiselect/wiki/Home
From the docs:

[quote]AUTOSELECT
In this mode, whenever you select anything it will “store” that selection and make it “sticky” so it stays selected.
You can move around in the document, edit it, and do whatever, just remember any selection you do it will get “sticky”.
If you select a “sticky” selection again it will a deselect that selection and it will no longer be “stored” or “sticky”
[/quote]

You could use this in a hackish sort of way to create multiple insertion points: select the character to the right of each insertion point you want, and then when you’ve got 'em all leave this mode, press the left arrow key, and you’re good to go. You could also edit the plugin or map these actions do different keystrokes (i.e. ctrl+i: “move characters 1 extend” to add an insertion point, then some key that leaves autoselect mode and also does “move characters -1”).

0 Likes

#12

adzenith,

Yeah, thanks. I guess I’m blind, cuz yeah, Find All does exactly what I’m wanting. I think I will map the same shortcut as well. :wink:

0 Likes

#13

[quote=“sublimator”]Multiselect was written before we had onSelectionModified event handler. I might actually rewrite it tomorrow cause right now it uses modal bindings to hijack the arrow keys to determine when you change selection. I’d rather make it global and it need some other quirks fixed to make it more friendly to use.

I use it fairly often actually and along with hotspots, I almost never reach for the mouse except for the occasional minimap or scrolling.

Alt f3 is pretty cool. Especially if you auto scope it to the local function.
http://blogdata.akalias.net/search-in-area.gif[/quote]

Woah ! How do You select the entire function ‘run’ ???
What do You mean by ‘Especially if you auto scope it to the local function’ ???
Ctrl-Shift-Space doesn’t work for me, do You have a custom Python Grammar ?

0 Likes

#14

Would be nice if X would have a built-in scope growing and shrinkage.

subliminator, I haven’t checked out this hackish magic, but the scoping is something I’ve been longing for since I really started developing some multi-select mojo.

I would think it would be nice to do scoping in the following manner:
cursor<->word<->paragraph<->function(if applicable)<->class(if applicable)<->buffer

or I guess a more flexible would just be incremental block scoping:
cursor<->word<->statement(maybe?)<->blockA(containing cursor)<->blockB(containing A)<-…->buffer

0 Likes

#15

The following default keybinding is pretty sweet:

It does this:
blockA(containing cursor)->blockB(containing A)->etc.
It doesn’t do the word thing by itself, but you can select a word with ctrl+d.

0 Likes

#16

Thanks sublimator for your answer.

Is it possible to define a scope that include all the content of a procedure/class in the grammar ?
I didn’t find any example in the standard packages of ST and even with the nice tutorial of guillermooo (http://www.sublimetext.info/docs/extensibility/syntaxdefs.html), it doesn’l look easy.

Define a multi-line scope without begin/end tag look like a complex task.

0 Likes