+4
Is it possible to execute a command instead of inserting content for snippets?
Say I have text like YYYY-MM-DD and want to replace it with the value 2011-03-22. I don't want to do this via a key binding but rather via a tab trigger. The trigger would be YYYY-MM-DD and a TextCommand could return the proper content.
Is that possible?
Customer support service by UserEcho
import sublime_plugin import datetime class DateCompleter(sublime_plugin.EventListener): def on_query_completions(self, view, prefix, locations): return [ ("YYYY-MM-DD", str(datetime.date.today())), ("YYYY", str(datetime.date.today().year)), ("MM", "%2d" % datetime.date.today().month), ("DD", "%2d" % datetime.date.today().day) ]I think the best way to achieve this is to allow something like this on a .sublime-completions file:
Is there any way to do it ?
{ "trigger": "date", "command": "today" },