Sublime Forum

Where can I put custom auto-completes?

#1

For example, in CSS files, for font-family one suggestion is Arial, Helvetica, sans-serif. I’d like to add “Helvetica Neue”, Helvetica, sans-serif

0 Likes

#2

Bump.

I’ve got a bunch of ‘custom markup’ the new company I work at uses. I would like to add this into some kind of auto-complete so I don’t have to remember it all - I could just CTRL + SPACE and find the correct item, right?

Anyway it links in with the original question: Where do I add custom auto-completes?

0 Likes

#3

For what it sounds like you’re talking about (I am in the same situation) you could create snippets with custom triggers.

For example, I found I had to often enter a private string variable in Action script often, so:

<snippet> <content><![CDATA[ private var ${1}:${2:String} = ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>pvar</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>source.actionscript</scope> </snippet> So, I can type “pvar” and tab.

However, in my post I was specifically referring to auto-completes (the menu that appears on ctrl-space), if there’s only 1 or two adds I want to make.

0 Likes

#4

You can create a “Default.sublime-commands” file either in the “User” packages directory or in any other packages directory.

Check out the command palette documentation for more details.

For some reason I seem to remember that the file has to be named “Default.sublime-commands” rather than “something_else.sublime-commands” or it won’t be recognized, although that might just be my imagination (or possibly an old bug that has since been resolved).

0 Likes

#5

Thanks, but those look like commands that will appear when I invoke the command palette.

I am talking about the popups (see attached)

0 Likes

#6

Hmmm…not sure, but maybe it can be done by adding a sublime-snippet?

0 Likes

#7

I have many snippets, which I can invoke with a tab-completion. But this is an existing set of completions, as optional completions for font-family. I just want to add my own font sets to that menu.

0 Likes

#8

bump?!

0 Likes

#9

To add more options to the ZenCoding autocompletions, you will have to add to Packages/ZenCoding/Scripts/css_metadata.xml

0 Likes

#10

To create completions you just need to create a file something like this:

{ "scope": "source.css", "completions": "inherit", "none", // other words.. { "trigger": "backgroundAttachment", "contents": "background-attachment: ${1:Fixed Scroll}${1/(f$)|(s$)|.*/?1:ixed:?2:croll/i};$0" } ] }
Save it with the extension ‘.sublime-completions’ and put it in either your User folder or the appropriate language folder. ‘source.css’ tells it to only work with .css files.

Andy.

0 Likes