Home Download Buy Blog Forum Support

[SOLVED]Autocomplete hide Snippet components

[SOLVED]Autocomplete hide Snippet components

Postby C0D312 on Wed Dec 21, 2011 7:04 pm

I just found out that you can add snippets within the autocomplete (Awesome, btw). Unfortunately, in the autocomplete window, it displays the $0, $1, etc. Please hide this.
Last edited by C0D312 on Wed Dec 21, 2011 7:53 pm, edited 1 time in total.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Autocomplete hide Snippet components

Postby quarnster on Wed Dec 21, 2011 7:26 pm

You do that yourself in the tuple returned by on_query_completions. The first item in the tuple is what is displayed to the user, the second item is what is actually inserted. So for example from the code I wrote here

Code: Select all
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)
        ]
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: [SOLVED]Autocomplete hide Snippet components

Postby C0D312 on Wed Dec 21, 2011 7:54 pm

@quarnster,

Awesome! Thanks so much.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 26 guests