【问题标题】:Move cursor after selected an item in autocompletion list在自动完成列表中选择一个项目后移动光标
【发布时间】:2017-06-26 14:52:09
【问题描述】:

我为 SublimeText 实现了一个自动补全插件

import sublime_plugin
import sublime

tensorflow_functions = ["tf.AggregationMethod()","tf.Assert()","tf.AttrValue()","tf.AttrValue.ListValue()", etc...]

class TensorflowAutocomplete(sublime_plugin.EventListener):

    def __init__(self):

        self.tf_completions = [("%s \tTensorflow" % s, s) for s in tensorflow_functions]

    def on_query_completions(self, view, prefix, locations):

        if view.match_selector(locations[0], 'source.python'):
            return self.tf_completions
        else:
            return[]

当用户在自动完成列表中选择一个项目时,有什么方法可以将光标移动到括号中? 我没有尝试任何东西,因为我在 API 文档中找不到我想要的东西。

【问题讨论】:

    标签: sublimetext sublime-text-plugin package-control


    【解决方案1】:

    您可以只在补全中使用 sn-ps,因此您将 tf.Assert() 更改为 tf.Assert($1)(使用制表符跳出)或 tf.Assert($0)

    如果所有括号都为空,您只需将代码更改为:

    self.tf_completions = [("%s \tTensorflow" % s, s.replace("()", "($1)") for s in tensorflow_functions]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-28
      • 2014-01-07
      • 1970-01-01
      • 2011-09-05
      • 2011-08-02
      • 1970-01-01
      相关资源
      最近更新 更多