Skip to content

Snippets Markers

Osaka edited this page Feb 4, 2025 · 2 revisions

Snippet markers are those comments that are replaced by your snippet code.

They have this structure:

--@<snippet-name>{#<arg-name> = <arg-value>}

-- Example:
--@foo{#hi=1}

Autocomplete

You can type an @ to get a list of all your snippets next to a small floating comment in your editor script

The "#" delimiter

The delimiter “#” is used to indicate that the text you are typing is a variable, it must be followed by an “=” next to a value.

--@foo{#hi=2}

With multiple variables (separed by spaces):

--@foo{#hi=2 #bye=4}

Marker Arguments

Snippets may or may not have arguments in their marker. The arguments of a snippets must be passed inside the {} of the marker, the space between the sarguments does not matter, they will not be taken into account, so you can do this:

--@foo{      #e   = 3  #b =  'hi' }

But it's not recommended, you should always do this:

--@foo{#e=3 #b='hi'}

Types allowed as arguments

Marker arguments can handle any datatypes, you can use functions call, dicts, tables, strings, ect.

Example:

--@foo{#x={b=4,c=4} #emoji=🎶 #string='hi'}

Good Practices

  • Never use double quotes to set string arguments, use single quotes
--@foo{#x="hi"} -- BAD
--@foo{#x='hi'} -- GOOD
  • Don't add spaces between the snippet marker (only to separate arguments)
--@ foo { #x = 1 } -- BAD
--@foo{#x = 1} -- BAD
--@foo{#x=1} -- GOOD
Clone this wiki locally