What I’d like to do is select some text, press a key or two, and then that text is loaded into the snippet, for me to save (ideally with the file name automatically generated) so I can just press save.
Let’s pretend that the text I’ve selected is Bob’s Big Banana.
If I select Bob’s Big Banana and then go to Tools => Developer => New Snippet I get:
<snippet>
<content><![CDATA[
Hello, ${1:this} is a ${2:snippet}.
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
what I’d like is:
<snippet>
<content><![CDATA[Bob's Big Banana
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>Bob's Big Banana</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
and the file name to be Bob’sBigBannana.sublime-snippet, and just be able to press enter (for the save)
I’ve tried saving a generic snippet:
<snippet>
<content><![CDATA[${TM_SELECTED_TEXT}]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>${TM_SELECTED_TEXT}</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.c++</scope>
</snippet>
but when I select, say, Bob’s Big Banana, and use crtl+shift+p to ‘use’ generic.sublime-snippet all i get is ${TM_SELECTED_TEXT} printed where Bob’s Big Banana was.
I’ve tried removing the ${} from TM_SELECTED_TEXT but no difference. I’ve tried logging commands to see what the ‘create new snippet command’ was so the perhaps I could bind it to a keybinding and pass an argument or two to it, but to no avail, it shows all commands expect the one where I create a new snippet.
Can this be done, because if so it would make snippets properly powerful ?
Thanks for your time in reading this.
Lozminda