3

I have got a sublime snippet to get console.log in js who look like that :

<snippet>
    <content><![CDATA[console.log('$1', $1);]]></content>
    <tabTrigger>cl</tabTrigger>
    <scope>text.html,source.js</scope>
    <description>console.log()</description>
</snippet>

I type cl tab and cmd+v and I got what i want.

What i really would like is to cl taband have the content of my clipboard inside the $1.

For the moment I have a small improvement:

<snippet>
    <content><![CDATA[console.log('$TM_CURRENT_WORD', $TM_CURRENT_WORD);]]></content>
    <tabTrigger>cl</tabTrigger>
    <scope>text.html,source.js</scope>
    <description>console.log()</description>
</snippet>

Which do the same but insert the word after the cursor when I hit tab.

Do someone have an idea to get the content of the clipboard inside the parameters? Or have a nice console.log snippet?

Thanks

@xavhan

1 Answer 1

0

Set up your snippet to use the currently selected text, and use a keyboard shortcut to trigger its usage instead of using a tabTrigger.

<snippet> <content><![CDATA[console.log('$SELECTION', $SELECTION);]]></content> <!-- <tabTrigger>cl</tabTrigger> --> <scope>text.html,source.js</scope> <description>console.log()</description> </snippet>

{ "keys": ["alt+z"], "command": "insert_snippet", "args": { "name": "Packages/User/snippets/console.sublime-snippet" } }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .