[TxMt] Surround with

Sune Foldager cryo at cyanite.org
Tue Jan 17 11:59:44 UTC 2006


On 17/01/2006, at 8:10, Nik Derewianka wrote:

> I need to:
> surround a selection with some additional text  ie   1,2 becomes [1,2]
> after selecting the 1,2

Make a command, in: selected text, out: replace selection. Then just  
make the command: echo "[$TM_SELECTED_TEXT]"

> on the line with the carat, trim any excess spaces from the end of  
> the line

For this one it's harder since commands don't let you do stuff like  
replace the current line, etc. (which I've needed a few times). You  
can make a command which strips the selection, and then a macro which  
select the current line and then fires the command.

As for how to make the command, I don't know of (but there might  
exist) a shell-tool for stripping. You could
#!/usr/bin/ruby
puts gets.strip

...although it's a bit overkill :-p.

-- Sune.




More information about the textmate mailing list