Are envirinment variables supported in snippets as they are in TextMate/E? I can’t get them to work. Specifically I’m trying to get ${TM_CSS_SPACE} working in SCSS and ${TM_XHTML} in the HTML package.
Environment vars in snippets?
Are these set dynamically? I believe vars defined in .tmPreferences files are visible in snippets since a few versions ago, but I don’t think others are.
I don’t know how they are done in TextMate, but in E you can set them on a per project basis.
Could you point me to any examples of how they’re set in .tmPreferences?
Check Build 2077 release notes.
I suppose you’d create a file similar to this (Comments (C++).tmPreferences for C++):
[code]<?xml version="1.0" encoding="UTF-8"?>
name Comments scope source.c, source.c++, source.objc, source.objc++ settings shellVariables name TM_COMMENT_START value // name TM_COMMENT_START_2 value /* name TM_COMMENT_END_2 value */ name TM_COMMENT_DISABLE_INDENT_2 value yes uuid 38DBCCE5-2005-410C-B7D7-013097751AC8 [/code]By the way, those TM_COMMENT_* are used by the comment/uncomment command. Not very useful for snippets, but you’d add your own following that pattern. (I’ve never tried to use such variables in snippets, though…)
Hmm, still can’t get it working. Here’s the tmPreferences file I’ve created:
[code]<?xml version="1.0" encoding="UTF-8"?>
name spacer scope source.css, source.scss settings shellVariables name TM_CSS_SPACE value uuid 0ef292cd-943a-4fb0-b43d-65959c5e6b06 [/code]It doesn’t recognise the space as the value. If I put another character in there, it gets correctly injected. Is there any way I can insert some sort of escaped space?
I’m not really good with XML, but maybe a CDATA section like in the .sublime-snippet files?
Yes, that did it. Nice one, thanks, I am indebted to you. Here’s my final file: gist.github.com/1083560 saved as spacer.tmPreference in my SCSS package.