Log in

View Full Version : Useful snippets for SWEL in Sublime



Hlynrian
August 30th, 2021, 11:41
Go to Tools-Developer-New Snippet and paste this, save as a familiar name, then set a new keybind in preferences to activate.

This one lets you dump a bunch of text into sublime, highlight it, then press a keybind to wrap that text in a new page. You can modify it to taste based on the project you are working on. The $1 does two things, the cursor will appear there when you add the page, and anywhere $1 is placed, the text you add to title will also appear there. You can also add $1, $2, $3...if you want to tab through a lot of fields such as a new piece of gear - and you want to add that manually.

<snippet>
<content><![CDATA[
[[###$1
@@chapter::Crown of the Kobold King
@@subchapter::

@@blocks.*.blocktype::header
@@blocks._.frame::picture
@@blocks._.text::$1

@@blocks.*.text::"""

$TM_SELECTED_TEXT
"""
]]
-------------------------------------------
]]></content>
<description>###Page</description>
<scope>text.html.basic</scope>
</snippet>

Example KeyBind:
// These are SWEL snippet commands, change NewPageSWEL to your chosen familiar name, and choose a key to bind.
[
{ "keys": ["ctrl+2"], "command": "insert_snippet", "args": { "name": "Packages/User/NewPageSWELL.sublime-snippet" } },
]

Hlynrian
August 30th, 2021, 11:52
This one just wraps a selected phrase or word in puts the bold asterisks around it. Easily modified for italics and underline. For these I use the same key bindings as fantasy grounds, ctrl+b for example.

<snippet>
<content><![CDATA[
**$TM_SELECTED_TEXT**
]]></content>
<description>bold</description>
<scope>text.html.basic</scope>
</snippet>