[TxMt] Better ways to add large number of really small snippets?

Alex Ross alex.j.ross at gmail.com
Tue Aug 14 01:45:05 UTC 2007


> One thing I use snippets for is as a simple, convenient memory aid;  
> for example, I currently have (most) of the Ruby standard exception  
> types as snippets with the tab trigger "exception". So I type in  
> "exception", tab, and get to choose which of the exceptions I  
> really want to use.
>
> However, defining and maintaining (in case changes are wanted) such  
> a large number of small snippets is sorta annoying when going  
> through the Bundle Editor. Is there a way to have multiple snippets  
> in one file, including the various settings such as tab trigger,  
> keyboard shortcut, etc.?

A better way to do this sort of thing is to write a command.   
Something like this:


#!/usr/bin/env ruby -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui"
exceptions = [
   'Exception',
   'AnotherException'
]
index = TextMate::UI.menu(exceptions)
STDOUT.write("${0:#{exceptions[index]}}")


Try creating a textmate command with these contents, set 'Input:  
None', 'Output: Insert as Snippet' and of course set Activation to  
'Tab Trigger: exception'.

The command is attached as well.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Exception.tmCommand
Type: application/octet-stream
Size: 1032 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20070813/0be62bc8/attachment.tmCommand>


More information about the textmate mailing list