gpt4 book ai didi

sublimetext - 在自动完成列表中选择一个项目后移动光标

转载 作者:行者123 更新时间:2023-12-03 13:37:25 27 4
gpt4 key购买 nike

我为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文档中找到想要的东西。

最佳答案

您可以仅在补全中使用代码段,因此可以将tf.Assert()更改为tf.Assert($1)(使用标签跳出)或tf.Assert($0)
如果所有括号都为空,则只需将代码更改为:

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

关于sublimetext - 在自动完成列表中选择一个项目后移动光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44762502/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com