Home Download Buy Blog Forum Support

complex key binding

complex key binding

Postby vim on Mon Nov 09, 2009 9:50 am

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="deleteRange ${motion}"><context name="option" value="ctrlMode"/></binding>
<namespace name="motion">
<binding key="j" command="lines 1"/>
<binding key="k" command="lines -1"/>
<binding key="d" command="lines 1"/>
<binding key="/\d+/" command="${motion} $1"/>
</namespace>

but it doesn't. am i doing it wrong, or it just not supported.
vim
 
Posts: 298
Joined: Tue May 27, 2008 6:51 pm

Re: complex key binding

Postby jps on Mon Nov 09, 2009 1:27 pm

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

Code: Select all
<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>
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: complex key binding

Postby vim on Mon Nov 09, 2009 1:36 pm

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.
vim
 
Posts: 298
Joined: Tue May 27, 2008 6:51 pm

Re: complex key binding

Postby artee on Mon Nov 09, 2009 7:25 pm

Another one...
Because of Sublime is growing up rapidly :) 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
artee
 
Posts: 32
Joined: Sat May 30, 2009 10:33 pm

Re: complex key binding

Postby EJ12N on Wed Nov 11, 2009 5:16 am

artee wrote:Another one...
Because of Sublime is growing up rapidly :) 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


++1 :) I would like this too...
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 24 guests