Sublime Text 2 - 自动完成/从其他文件建议

发布于 2025-01-01 10:02:31 字数 325 浏览 1 评论 0原文

假设我有 2 个文件:

foo
bar
baz

如果

123
456
f[want autocomplete here]

我在第二个文件中输入 1,Sublime 会建议 123。但如果我输入 f 它不会提示任何内容。我希望它像我在第一个文件中一样建议 foo

看起来这应该很简单(每个缓冲区都可以自动完成,因此搜索所有缓冲区不会那么困难),但我一直无法找到执行此操作的插件。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深陷 2025-01-08 10:02:31

我实现了相同的想法并将其发布为包,以便可以使用包控制直接从 Sublime 中安装:

按 ctrl+shift+p(Windows、Linux)或 cmd+shift+p(OS X)打开命令调色板。开始输入“安装”以选择“包控制:安装包”,然后搜索 AllAutocomplete 并选择它。

代码在这里: https://github.com/alienhard/SublimeAllAutocomplete

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

葬花如无物 2025-01-08 10:02:31

我写了一个插件来执行此操作:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文