[TxMt] Insert as Snippet: tmCommand versus tmSnippet

Hans-Jörg Bibiko bibiko at eva.mpg.de
Sat Mar 31 20:20:24 UTC 2007


Hi,

is there any difference to insert something as snippet by using a  
normal tmSnippet and tmCommand which is set to the output 'Insert as  
Snippet' and input 'selected text or line'?

My problem:

I have a document containing the line:

build_cpu=`echo $ac_cv_build |  sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/ 
1/'` ;


At the end of that line I'd like to insert a snippet '${1:Hallo} 
World'. If I do it via a tmSnippet it works perfectly. But if I write  
a tmCommand à la:

Command:
in=$(cat)
caret=$TM_COLUMN_NUMBER-1
lnhead=${in:0:$caret}
lnend=${in:$caret}
echo -en "$lnhead\${1:Hallo}World$lnend"

Output: Insert as Snippet
Input: sel. text or line

it crashes, meaning TM inserts: 'build_cpu= ; HalloWorld'.

Maybe TM has some problems while parsing the line? But as tmSnippet  
it works?
If you change the output to 'Show as Tooltip' the command did the job  
correctly. I only can guess that if in the line occurs a '$' TM will  
have problems. And if this is true, what can I do? I already tried to  
escape all '$' in the variable 'in' but no success.

Any hint would be very helpful. The example as tmCommand I attached  
to this mail.

Thanks,

Hans

-------------- next part --------------
A non-text attachment was scrubbed...
Name: SnipProblem.tmCommand
Type: application/octet-stream
Size: 804 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20070331/57286bdd/attachment.tmCommand>
-------------- next part --------------





More information about the textmate mailing list