[TxMt] Re: Code folding questions

Allan Odgaard mailinglist at textmate.org
Mon Aug 22 09:15:17 UTC 2016


On 22 Aug 2016, at 10:50, Fabian Zeindl wrote:

> I thought about overloading Cmd+Return anywhere inside the 
> parentheses, but I'd need a selector for this first. Best would be If 
> I could get the "match enclosing pairs" as a command input.

You can create a macro that first does the selection, then executes a 
command, e.g.:

	(
		{	command = 'selectBlock:'; },
		{	command = 'executeCommandWithOptions:';
			argument = {
				name = 'Convert Block';
				command = '#!/usr/bin/env ruby
	print "your code here…"';
				input = 'selection';
				output = 'replaceSelectedText';
			};
		},
	)

This though leaves your insertion selected, there are other options, 
like asking for caret to be after insertion, but you probably want to 
keep the caret where it was.

You lose the caret when you do the selection, one way could be to insert 
a magic placeholder before doing the selection, then find this in your 
command, and produce a snippet where the placeholder is replaced by 
`${0}` (to indicate where caret should go).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20160822/673bc5de/attachment.html>


More information about the textmate mailing list