簡體   English   中英

在自動完成列表中選擇一個項目后移動光標

[英]Move cursor after selected an item in autocompletion list

我為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()更改為tf.Assert($1) (跳出制表符)或tf.Assert($0)

如果所有括號都為空,則只需將代碼更改為:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM