[TxMt] Creating temporary snippets using TMTOOLS
Hans-Joerg Bibiko
bibiko at eva.mpg.de
Wed Oct 17 10:58:46 UTC 2007
On 16 Oct 2007, at 21:31, Robin Houston wrote:
> On 16/10/2007, Thomas Aylott <textmate at subtlegradient.com> wrote:
>> This already exists.
>> See "TextMate > Scratch Snippet > Record" & "… Insert"
>
It is only an idea ;)
I often thought about to make it possible to use temporary snippets
bound on temporary keys.
My approach with TMTOOLS:
-I have a TM document which is saved anywhere but it must have
'AUTOTEXT' in its name
-In that file I can write temporary snippets à la KEY SPACE SNIPPET -
each row is one entry
-I have a tmCommand like:
KEY=$(cat)
[[ -z "$KEY" ]] && echo -en "\t" && exit_insert_text
SNIPPET=$("$TMTOOLS" get autoTextWindowsContent | egrep ^"$KEY ")
if [ -z "$SNIPPET" ]; then
"$TMTOOLS" goto nextSnippetField
exit_discard
else
echo -en "${SNIPPET:${#KEY}+1}"
exit_insert_snippet
fi
input: selected text or word
bound to TAB
Example:
http://www.bibiko.de/TMautotext.mov
Workflow:
If the 'AUTOTEXT' file is not open everything goes normally.
If I open that file and I edited it to insert a snippet (one hasn't
to save it because TMTOOLS get its current content) I can use these
temporary snippets.
Meaning if I press TAB the command looks for an equivalent key in the
'AUTOTEXT' file. If there is one it will take this, otherwise it
sends TAB to TM.
This works perfectly but one tiny things is there: speed. If I use a
snippet coming from 'AUTOTEXT' like the example 'abcd' and I press
TAB it takes ca. 200ms to jump to the next snippet field, or better I
see it 200ms later. I can type very fast, everything is ok, but I see
it a tick later.
Nevertheless my question is whether this workaround would be useful
to elaborate further?
--Hans
More information about the textmate
mailing list