[quote=“FichteFoll”]Okay, let me phrase it like this: In order to do what you want to you have to write a Python plugin.
If you are not known to Python, well, go ahead and learn it, it’s awesome.
If you are, I think you can put some sense into these examples (with the API documentation):
API: sublimetext.com/docs/2/api_reference.html
Docs on plugins: docs.sublimetext.info/en/latest/ … ugins.html
Specifically about completion plugins: docs.sublimetext.info/en/latest/ … tions-list
More advanced example from “Packages/HTML/html_completions.py”:
[code]# This responds to on_query_completions, but conceptually it’s expanding
expressions, rather than completing words.
It expands these simple expressions:
tag.class
tag#id
class HtmlCompletions(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
# Only trigger within HTML
if not view.match_selector(locations[0],
“text.html - source - meta.tag, punctuation.definition.tag.begin”):
return ]
# Get the contents of each line, from the beginning of the line to
# each point
lines = [view.substr(sublime.Region(view.line(l).a, l))
for l in locations]
# Reverse the contents of each line, to simulate having the regex
# match backwards
lines = [l[::-1] for l in lines]
# Check the first location looks like an expression
rex = re.compile("(\w-]+)(.#])(\w+)")
expr = match(rex, lines[0])
if not expr:
return ]
# Ensure that all other lines have identical expressions
for i in xrange(1, len(lines)):
ex = match(rex, lines*)
if ex != expr:
return ]
# Return the completions
arg, op, tag = rex.match(expr).groups()
arg = arg::-1]
tag = tag::-1]
expr = expr::-1]
if op == '.':
snippet = "<{0} class=\"{1}\">$1</{0}>$0".format(tag, arg)
else:
snippet = "<{0} id=\"{1}\">$1</{0}>$0".format(tag, arg)
return (expr, snippet)][/code]*
Thanks ill look into that
[/quote]