Sublime Forum

Request for commands

#1

I thought I’d add these myself but then found I can’t get the source code so I’ll pop a request here in the hope it can be added.

First off, a command to clear the selection would be very welcome. This doesn’t seem to make too much sense yet but it does in the broader context of what I propose below. It’s the lowest priority of the feature requests I present.

Next up are three related commands (the command names are just an example):

  • auto_select_on - this acts like shift is being held down for the various navigation commands (cursor keys, page up/down, home/end, etc)
  • auto_select_off - stops the above behaviour
  • auto_select_toggle - for completeness (although it’s not one I’d personally want!)

This way, I could hit a key which is bound to auto_select_on at the start of my selection and then navigate around to where I want it to end then hit a key bound to auto_select_off. I could also have a single key to toggle the behaviour but that’s not how my existing preferred editor works.

In my dream world, the selection would then persist even if I do more navigation-type commands to move around my source code. That way, I can page down a bit to look at stuff before making a decision about whether to cut or copy or whatever the selection. Or, I could hit the key I’ve bound to the new clear_selection command…

If anyone has ever used Zap or StrongED on RISC OS, they will know exactly what I’m talking about and realise just how powerful this mode of operation can be over the very transient selections seen in other editors. I’d love to see this in ST2 (or ST3) - it already does 95% of what I want, which is about 45% more than any other Linux/Windows editor. Cool.

0 Likes

#2

You may be able to use MultiBind to achieve this. It allows you to create arbitrary modes and use them as a context for keybindings.

Thread: viewtopic.php?f=5&t=11625#p45716
Git: github.com/KonTrax/MultiBind

Hope this helps,
Alex

Edit: corrected URL

0 Likes

#3

You could easily make a plugin to do the following:
Hotkey1: save current keyboard caret position in a static variable named var1.
Hotkey2: select all text between var1 and current keyboard caret position. Or assign it a custom region such as a bookmark region which would you allow to keep moving around the document and return to it later via “prev_bookmark” and “next_bookmark”.

0 Likes

#4

I don’t know anything about Zap or StrongED but from the sound of it, quodlibet’s solution would be best. For the commands, you can look up the “shift+” variants of the navigation commands in the default key map. I think all these do is add the “extend: true” argument to the movement command. If I recall, the multibind plugin only has the toggle, rather than defined on/off commands, but it may still work for you. If not, perhaps make a feature request to have a separate on/off command.

0 Likes

#5

You’re right about the toggle, but you can create an “off” command as follows:

{ "keys": "super+s"], "command": "multibind_toggle", "args" : { "layout": "select-mode" } },
{ "keys": "escape"], "command": "multibind_toggle", "args" : { "layout": "default" }, "context":  { "key": "multibind.select-mode" } ] },

“Escape” in this example will only work when the layout is on “select-mode”; the context guarantees that the toggling will be in the “off” direction.

If the OP plays around with this, please throw up some code :smile:

Hope this helps,
Alex

0 Likes

#6

Thanks for the pointers - I’ll definitely look into these when I’m back home in a week or so.

0 Likes