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

Thomas Aylott (subtleGradient) oblivious at subtlegradient.com
Tue Aug 14 03:04:59 UTC 2007


You might also be interested in the CodeCompletion stuff.
It does something similar to what Alex suggests but has some nice  
features specific to completing code.
It'll find where your caret is and use the characters to the left of  
your caret to filter the list of completions.
It'll also snippetize the completion to let you tab into quotes and  
stuff.
It's what is used in the HTML & CSS bundles for completions. And a few  
other places.

#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion"
print TextmateCodeCompletion.new(["something","something  
else","etc..."],STDIN.read).to_snippet

input: current line or selection
output: snippet


Or you could even make some preference items in your personal bundle  
like this:

{	shellVariables = (
		{	name = 'TM_COMPLETIONS';
			value = 'something,something else,etc...';
		},
	);
}

And then set the scope to only give you that list in certain places.

And write a command like this that works with multiple lists with the  
same shortcut:

#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/codecompletion"
print  
TextmateCodeCompletion 
.new(ENV['TM_COMPLETIONS'].split(','),STDIN.read).to_snippet


	thomas Aylott — subtleGradient — CrazyEgg — bundleForge

On Aug 13, 2007, at 10:27 PM, Kenneth McDonald wrote:

> Ah, my heart is pounding...I hadn't stumbled across TextMate::UI yet  
> (actually, haven't really looked
> at programming textmate yet), so it's time to start!
>
> Many thanks,
> Ken
>
> Alex Ross wrote:
>>




More information about the textmate mailing list