Reputation: 21519
Say I have 2 files:
foo
bar
baz
and
123
456
f[want autocomplete here]
If I type 1
in the 2nd file, Sublime will suggest 123
. But if I type f
it wont suggest anything. I want it to suggest foo
like it would if I were inside the first file.
It seems like this should be simple (each buffer can autocomplete, so searching all of them can't be so hard) but I haven't been able to find a plugin that does this.
Upvotes: 39
Views: 23913
Reputation: 14692
I've implemented the same idea and published it as a package so it can be installed directly from within Sublime with Package Control:
Press ctrl+shift+p (Windows, Linux) or cmd+shift+p (OS X) to open the Command Pallete. Start typing 'install' to select 'Package Control: Install Package', then search for AllAutocomplete and select it.
Code is here: https://github.com/alienhard/SublimeAllAutocomplete
Upvotes: 104
Reputation: 21519
I wrote a plugin that does this:
import sublime_plugin, sublime
class AutocompleteAll(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
window = sublime.active_window()
# get results from each tab
results = [v.extract_completions(prefix) for v in window.views() if v.buffer_id() != view.buffer_id()]
results = [(item,item) for sublist in results for item in sublist] #flatten
results = list(set(results)) # make unique
results.sort() # sort
return results
Upvotes: 17