[TxMt] Re: Bundle to wrap at x characters wide

Rob McBroom mailinglist0 at skurfer.com
Fri May 15 12:52:03 UTC 2009


On 2009-May-15, at 1:23 AM, Scott Haneda wrote:

> Hello, usually I will option draw a box around some text, press
> control-Q and it wraps it with hard line breaks.  Handy.
>
> I would like to define this in a more exact way, and set up a bundle
> that does the same thing, to selected text, at say, 80 chars wide.
> Not right on the 80 of course, take into account in the same way
> control-Q does, where a word ends.

I don't know about selecting to a specific width (maybe a macro?), but  
you can certainly wrap to a specific width in a number of ways.

One way is to go to View → Wrap Column and set something there. Of  
course, that affects all files in all languages, but it works.

Another way is to make a command that runs the text through the `fmt`  
command. (Such a command probably already exists, so you might want to  
look around in the bundles.) You can then assign that command to all  
scopes, or just the ones you want to be different from the default.

Some bundles have already replaced ⌃Q, so you might want to see what  
they've done. For instance, the Mail bundle's re-wrap command knows  
how to wrap quoted lines beginning with one or more '>'. I modified it  
to always wrap at 74.

-- 
Rob McBroom
<http://www.skurfer.com/>

The magnitude of a problem does not affect its ownership.








More information about the textmate mailing list