I tend to use snippets a lot in textmate because they help me standardize my data (text files, reports, blogs, wiki pages, code, etc). I wanted to know if there was anyway (or any planned features) that would allow the use of a temporary snippet, so that someone can:
1. while working in a file goto a blank line 2. type in some snippet code 3. highlight the code 4. hit a key combo to copy the snippet into a temp register/key that can then instantly be used in the document.
For example, say I'm writing a document that has is starting to use a bunch of citations: "Begin with the name of the author, moderator, or other responsible person or organization, if available, followed by the date of publication, the title of the site, the URL, and the date of access. (ex: American Chemical Society. (2006). Chemistry.org. http:// www.chemistry.org/portal/a/c/s/1/home.html (24 Mar. 2006).)"
So on a blank line I type:
$1. ($2). $3. http://%244 ($5).
I then select the text, and copy it to a temp register[1], (perhaps with a fixed tab trigger, or hot key) and now I can quickly call on it to populate the rest of my document.
This would save me time without having to goto snippets, create a new snippet, assign a name, key combo, code, etc, then use the snippet, and after I'm done with the document, go back in and delete the snippet.
I find I love the use of the snippets, but sometimes a formating issue is only needed once, not enough to warrant creating permanent snippets.
[1]: If there were 3-4 registers, then that would be even better.
---- Brian H binarynomad@gmail.com http://www.binarynomad.com
It's very easy to rig up something like this. The attached commands "create temporary snippet" and "use temporary snippet" show one simple way to do it: add key equivalents to taste.
Robin
On Oct 16, 2007, at 2:58 PM, Robin Houston wrote:
It's very easy to rig up something like this. The attached commands "create temporary snippet" and "use temporary snippet" show one simple way to do it: add key equivalents to taste.
Robin <create temporary snippet.tmCommand><use temporary snippet.tmCommand>
This already exists. See "TextMate > Scratch Snippet > Record" & "… Insert"
—Thomas Aylott – subtleGradient—
On 16/10/2007, Thomas Aylott textmate@subtlegradient.com wrote:
This already exists. See "TextMate > Scratch Snippet > Record" & "… Insert"
Ah! I hadn't spotted that one. Thanks.
Robin
On 16 Oct 2007, at 21:31, Robin Houston wrote:
On 16/10/2007, Thomas Aylott textmate@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
On Oct 16, 2007, at 11:09 AM, Brian Huddleston wrote:
I tend to use snippets a lot in textmate because they help me standardize my data (text files, reports, blogs, wiki pages, code, etc). I wanted to know if there was anyway (or any planned features) that would allow the use of a temporary snippet, so that someone can:
There is already support for this under Gear->Textmate->Scratch Snippet. It does have a tiny bug where if you have noclobber set in bash it will fail when trying to create a second snippet, but that's pretty easy to fix by removing the file before writing the new one.
[1]: If there were 3-4 registers, then that would be even better.
It would probably be pretty to extend the existing code to do this; just have a look at how the existing scratch snippet is implemented.