Sublime Forum

Cyclic autocomplete suggestions

#1

Is it possible to loop through the autocomplete suggestion in a cyclic way, so if you reach the bottom, you are automatically moved up to the first suggestion?
Im writing a plugin that heavily uses autocomplete suggestions and I find that feature very handy.

Thanks

0 Likes

#2

I use the following set of key-bindings to enable me to use Ctrl-Alt-Left and Ctrl-Alt-Right to cycle through the completions. It is not moving up and down the displayed completions list, but it does cycle back to the top (or bottom).

[code]
{ “keys”: “ctrl+alt+right”], “command”: “insert_best_completion”, “args”: {“default”: “”, “exact”: true} },
{ “keys”: “ctrl+alt+right”], “command”: “insert_best_completion”, “args”: {“default”: “”, “exact”: false},
“context”:

		{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
	]
},
{ "keys": "ctrl+alt+right"], "command": "replace_completion_with_next_completion", "context":
	
		{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
		{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
	]
},
{ "keys": "ctrl+alt+left"], "command": "replace_completion_with_prev_completion", "context":
	
		{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
		{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
	]
}[/code]

Also,it will break if there is an odd (word-ending) character in one of the completions.

I do not know if this is possible with the visible completions-list (but have doubts…).

0 Likes

#3

Thanks! Thats a great idea and trick, but unfortunately its not was I was looking found since I have many completitions candidates and I would prefer to use the dropdown menu to look for the right one.

0 Likes

#4

I personally don’t know if you are able to do anything with the ui-completions-list itself, other than up, down, esc, tab or enter. The question arises as to why you have so many similar completions, and doesn’t fuzzy-seach overcome this. If you are writing a plug-in then you might use on_query_completions to cut down the number of items listed. But I assume you’ve already considered these points :wink: .

0 Likes