Home Download Buy Blog Forum Support

Formatting and replacing line with Snippet

Formatting and replacing line with Snippet

Postby iota on Mon Mar 11, 2013 5:10 pm

I have the following snippet:

Code: Select all
<snippet>
    <content><![CDATA[console.log( ${TM_CURRENT_LINE/;$/$1/m}$0);]]></content>
    <tabTrigger>conl</tabTrigger>
    <scope>text.html,source.js</scope>
    <description>console.log()</description>
</snippet>


Which will wrap a line/selection with console.log(); replacing any ';' characters in the line. This is what I want if I select the line, but If I run the snippet (via a key binding) on a line without selecting text, it will duplicate the text.

Ex:

Code: Select all
// If I trigger the keybinding while the cursor is at the beginning of the following line, with no text selected:
exampleFunction()
// becomes...
console.log( exampleFunction()); exampleFunction();


I'd prefer it replace the whole line. Is this possible?
iota
 
Posts: 8
Joined: Fri Nov 18, 2011 5:43 pm

Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot], jasonc, Yahoo [Bot] and 27 guests