Sublime Forum

How can I get (*) symbol in snippet?

#1

I want to create a snippet for comment which would look like:
/****************

  • HEADER *
    ****************/

So, how do I get an astroid (*) icon for each letter I type in my snippet?

0 Likes

#2

Snippets allow you to perform regex expansions on fields (see here), so you can do this by including a mirrored field on the first and last lines specifying a regex to replace every character you type with an asterisk.

For example:

<snippet>
    <content><![CDATA[
/****${1/./\*/g}
 * ${1} *
 ****${1/./\*/g}/
]]></content>
    <tabTrigger>hdr</tabTrigger>
</snippet>

This snippet creates output similar to this:

/**********
 * HEADER *
 **********/

You can play with the number of asterisks on the first and last line as place holders to get it to look the way you want; for example your original has start and end lines that are far longer than the text inside, which if intentional is easy to tweak.

2 Likes

#3

Perfect; solved my issues perfectly.
Thanks buddy!

1 Like