Sublime Forum

Complex key binding

#1

hi,

i want to emulate VIM way of entering a number followed by command, so if ‘dd’ is used to delete 1 line, ‘d3d’ will remove 3 lines etc.

e.g. i would like the following to work:





<binding key="/\d+/" command="${motion} $1"/>

but it doesn’t. am i doing it wrong, or it just not supported.

0 Likes

#2

That won’t work, but you should be able to do it via the not too much more verbose:

<namespace name="motion">
    <binding key="j" command="lines 1"/>
    <binding key="/(\d+)/,j" command="lines $1"/>
    <binding key="k" command="lines -1"/>
    <binding key="/(\d+)/,k" command="lines -$1"/>
    <binding key="d" command="lines 1"/>
    <binding key="/(\d+)/,d" command="lines $1"/>
</namespace>
0 Likes

#3

hmm, it was just an example. i wanted it in a more general way, for all the key bindings. in VIM when you start with integer followed by another command it is just like repeat X, so i thought of doing it in general. thought it could be nice ability.

anyway, thanks.

0 Likes

#4

Another one…
Because of Sublime is growing up rapidly :smile: and there are a lot of packages available it causes problem with keys binding.
Sometimes they are overwritten by another one and it’s hard to determine which sublime-keymap and binding is used.
I think it would be good idea to add something like development or test mode to Sublime (new parameter or option) to display small window or something like this where user will be able to display which sublime-keymap files are used and which binding key/keys is/are triggered when you are pressing given key.

Regards,
Artur

0 Likes

#5

[quote=“artee”]Another one…
Because of Sublime is growing up rapidly :smile: and there are a lot of packages available it causes problem with keys binding.
Sometimes they are overwritten by another one and it’s hard to determine which sublime-keymap and binding is used.
I think it would be good idea to add something like development or test mode to Sublime (new parameter or option) to display small window or something like this where user will be able to display which sublime-keymap files are used and which binding key/keys is/are triggered when you are pressing given key.

Regards,
Artur[/quote]

++1 :smile: I would like this too…

0 Likes