Sublime Forum

Inserting dynamic text in a Snippet based on a setting

#1

I am very new to Sublime Text Plugin API, so I need some assistance with the mentioned problem below.

This is the Current Situation.

I have a bunch of snippet files,
eg:

<snippet> <content><![CDATA[ $TM_CONTEXT.rotate(${1:Rotate Angle}); ]]></content> <description>rotate(rotateAngle)</description> <tabTrigger>ro</tabTrigger> <scope>source.js</scope> </snippet>

That make use of an custom env variable called $TM_CONTEXT

[code]<?xml version="1.0" encoding="UTF-8"?>

name Globals scope settings shellVariables name TM_CONTEXT value uuid 4cbfd5b7-9dcc-46bb-be6f-2858e42e8aba [/code]

But the problem is when I package it for other users, they are not able to edit this .tmPreference file to customise the value of the $TM_CONTEXT

Now here’s what I intend to do:

  1. Is there any way I can let the end user edit the .tmPreference file after they install this plugin from Package control OR

  2. How do I accomplish this using Python API(‘insert_snippet’) and and a Settings File,

I am really sorry for making a very generic question like this but any help is appreciated.

0 Likes