Home Download Buy Blog Forum Support

snippets, custom "contexts"

Re: snippets, custom "contexts"

Postby jps on Thu Mar 27, 2008 6:59 am

tab is currently used for snippets, for example, type d,e,f,tab in python to insert a method. This is done via a sequential key binding (literally key="d,e,f,tab" in this case) - there's no need for contexts here.

I've got an item on the todo list to allow regex matches for contexts, which would do what you want for autocomplete, something like:

Code: Select all
<binding key="tab" command="insertAndDecode \t">
   <context name="matchPreceeding" value="(^|[\t ])$"/>
</binding>
<binding key="tab" command="autoComplete"/>


There's no support for defining contexts in plugins, but I'll add it to the list.

re: disabled commands, currently no, that'll still eat the key sequence.

Sublime actually has some pretty cool key binding functionality I've been meaning to blog about. Character sequence bindings, for example, work quite nicely, if you bind:

Code: Select all
<binding key="q,q" command="expandSelectionTo line"/>


Then the key sequence q, q will then do the same job as Ctrl+L, but without as much need to move your fingers. The nice part is that it wont bother you when you're trying to type, say, 'quickly', as the typing is predicted, and then rolled back if the second q comes along. It's worth have a play with anyway.

You can bind to regular expressions too, which is used in the HTML snippets (take a look at Packages/HTML/Default.sublime-keymap).

To extend the example above:

Code: Select all
<binding key="/([0-9]+)/,q,q" command="times $1 expandSelectionTo line"/>


Now typing 3,q,q will select three lines.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: snippets, custom "contexts"

Postby adrian on Thu Mar 27, 2008 7:07 am

jps wrote:Sublime actually has some pretty cool key binding functionality I've been meaning to blog about. Character sequence bindings, for example, work quite nicely, if you bind:


That's awesome, seems similar to how it works in vi - should ease the finger dance ;)

Thanks for the tip.
adrian
 
Posts: 3
Joined: Thu Mar 20, 2008 9:55 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests