[TxMt] Re: help writing a command
Kyle Johnson
kbj at linguist.umass.edu
Mon Jul 9 12:07:51 UTC 2012
Quoting Hans-Jörg Bibiko <bibiko at eva.mpg.de>:
>
> On Jul 8, 2012, at 2:53 PM, Kyle Johnson wrote:
>
>> I'm not savvy enough to see how to write a simple command for
>> Textmate 2, and I'm wondering if anyone can help get me started.
>>
>> The command should search the current file for "ch:\d" where \d is
>> one or two digits and spit that/those digits out where the cursor is.
>
> Could you please give us an example or be more specific? Spit out:
> where to? What do you mean with "where the cursor is"?
>
> This regular expression will match "ch:" followed by one or two digits:
>
> ch:(\d{1,2})
>
> and the regex variable $1 contains the found digit(s). Then the
> question arises whether ch:123 could occur as well? Etc.
Thanks for the quick reply, Hans.
I'll give a fuller description of what I'm trying to do.
I want a Textmate command that inserts into a LaTeX document a \label
tag whose shape depends on the value for "ch:nn" . ("ch:nn" will be in
a \label{ch:nn} tag at the top of the document, and will store the
number of the chapter that the file is.) The label's shape will be
"\label{exnn:}", where "nn" is the number found in the \label{ch:nn}
tag at the top of the file and "\label{ex:}" if there is no
\label{ch:nn} tag at the top of the document. Once the "\label{ex:}"
or "\label{exnn:}" tag is inserted into the file, I want the cursor to
be placed right after the colon.
I'm not fluent in regex, although the documentation is clear enough
for me to hobble through it. But Ruby, or the like, is a steeper climb
for me. So, it's the do-a-search-and-print- the-results part of the
process that I'm stymied by.
Thanks again
Kyle
More information about the textmate
mailing list