Search code examples
sublimetext3sublimetext-snippet

Sublime Text 3 path snippet issue


I just want to select 'folder*' and 'filename' to edit but I can't, below code does not work for me.
This file path with screenshot.

enter image description here

So I just try to write snippet code for 3 fields like below.

"\\\${1:folder1}\\\${2:folder2}\\\${3:filename}.jpg"

Second issue

enter image description here

I just try to write code for '0' (zero).
Thanks in advance.


Solution

  • I'm going to assume you want a snippet to complete to what's shown in the screenshot. In that case your “code” does not work because you're escaping the $, which makes your snippet useless.

    If you want to get a literal $, you have to escape it like this: \$.

    Instead, you want to add another backslash to expand the snippet with two backslashes in place.

    This following will expand with \\ and tab-stops in place:

    <snippet>
        <content><![CDATA[
    "\\\\${1:folder1}\\\\${2:folder2}\\\\${3:filename}.jpg"
    ]]></content>
    </snippet>
    

    Regarding your second issue: there are two ways to create tab-stops, with default values (e.g. ${1:default_value} and without (e.g. $1). So, you should use ${1:0} if you want it to contain 0 by default.