Sublime Forum

Autocompletion keybindings

#1

I’m used to the following autocompletion behavior: Lets type

this.computeSlug();

So I type this. and autocompletion pops. I start typing compute and it selects the correct method. Then I follow with a ( and it selects the correct item from the autocompletion list and closes, closing the bracket with ). Sublime just closes the autocompletion window and types in a ( without completing the item. Result:

this.compute(

Same thing, except with a . (dot). Lets type

this.object.property

I usually finish typing this., followed with obj and the correct item from the list gets selected. When I type a . (dot) wishing to access the object’s property, Sublime just closes the autocompletion window and types in a . without completing the item. Result:

this.obj.

I think this would be a great feature and pretty easy to do. I’ve tried editing the keybindings and adding ( and . :

[code]{ “keys”: “(”], “command”: “commit_completion”, “context”:

    { "key": "auto_complete_visible" },
    { "key": "setting.auto_complete_commit_on_tab", "operand": false }
]

}[/code]

This does not work as expected, because it does not insert the character, just selects the item from the autocompletion list. Looking at the keybindings manual, there is no way to bind 2 commands to be executed one after another, otherwise I could just do an insert command.

TLDR: make (, . and ; select the item from the autocompletion list and insert them into the code.

0 Likes

#2

I may be wrong but it sounds like you’re looking for the auto_complete_triggers field in File Settings. Open up File Settings - Default and look for "auto_complete_triggers": {"selector": "text.html", "characters": "<"} ]

You can add something like this to your File Settings - User: "auto_complete_triggers": {"selector": "YOUR_LANGUAGE.source", "characters": "(.;"} ]

0 Likes

#3

Nope. That options just opens autocomplete on those keys, which has nothing to do with the problem.

0 Likes

#4

Alright, I reread your post. You could try changing your word separators in your File - Settings. Remove “.” and “(”

This might cause some weird results in Sublime. Specifically if you select things by words, etc. It’s worth a shot though.

0 Likes