[TxMt] R request: tab moves through list when cursor in collection

Timothy Bates timothy.c.bates at gmail.com
Tue Apr 24 10:52:24 UTC 2007


Thanks Hans,
>> So if the cursor is in item 1 like this
>>> a = c(1|11,222)
>> 
>> Then hitting tab would move to highlight all of item 2.
> 
> To do so as you described is a bit complex but doable. A very naïve
> approach would be to use the attached two things:
> 
> EditVector.tmMacro (key bound to SHIFT+CTRL+V in scope source.r)
> - which calls TM's Find function to select a given vector c(.*?) in
> the current line
> - and calls EditVector.tmCommand
> 
> EditVector.tmCommand:
> - which splits the selection (delimiter := ',') into snippet items
> - and replaces the selection with a snippet for all items within the
> vector

Running the macro, I get an error

> interpreter failed: Exec format error

I imagine it is in the Perl
#!/usr/bin/perl -X
$i=1;
$sel= $ENV{'TM_SELECTED_TEXT'};
$sel=~s/^c {0,}\( {0,}//;$sel=~s/ {0,}\)$//;
for(split(/ *, */,$sel)) {push(@out, "\${".$i++.":$_}")}
print "c(".join(", ", at out).")\${".$i."}";


Cheers,
tim
-- 
The word "scientist" did not exist before 1833, when William Whewell
invented it during a meeting of the British Association for the Advancement
of Science (in response to a comment by Coleridge ‹the poet!‹ commenting
derogating empirical science by comparison with ³Natural Philosophy² (which
Coleridge thought he was doing).

Whewell argued from an analogy to the word Artist. It took until the 1900s
for the word to become common.

Learn about the Scottish Enlightenment
<http://www.ed.ac.uk/explore/av/enlightenment2006/>





More information about the textmate mailing list