[TxMt] snippet and command questions (toggle comments, hard-wrap, etc.)

James Edward Gray II james at grayproductions.net
Wed Oct 4 14:28:01 UTC 2006


On Oct 4, 2006, at 9:10 AM, Jason Moore wrote:

> Hi,
>
> I'm a new to textmate and loving it so far. i have a couple of  
> questions that i've saved up after my first week of use that i was  
> hoping someone could help me with:
>
>
> * i find that snippets make it easy to add text - but i'm not so  
> sure how to modify existing text. e.g. i find i am always  
> commenting out code in css, so i added this snippet (and bound to a  
> key):
>
> /* $TM_SELECTED_TEXT */
>
> great! ok, now how would i remove comments? (or even better, how to  
> toggle comments on the current line?)

Did you try command-/?  ;)  It's Comment Line / Selection in the  
Source bundle.

> * hard-wrap: i know textmate doesn't support this out of the box,  
> but with vi i always used "fmt". so here's my command which i bound  
> to a key:
>
> fmt << ___END___
> $TM_SELECTED_TEXT
> ___END___
>
> this isn't ideal (what if the text has ___END___ in it? fmt barfs  
> on non-ascii, and i always get an extra newline.) is there a better  
> way?

Does control-Q help at all?  That's Reformat Paragraph in the Text menu.

I believe you can change the command above to:

   fmt <<< $TM_SELECTED_TEXT

> * some snippets show a series of options, which you cannot select  
> (they just get erased when you start to type.) what's the idea -  
> just a simple reminder - or am i using it wrong? e.g. in the css  
> bundle:
>
> list-style-type: ${1:none/disc/circle/square};$0

Yes, it's intended as a reminder.

> why not just make 4 snippets - so then you get the popup and can  
> choose which one? (so i could hit '1' instead of typing in 'none'.)

You could certainly do that.  It will probably be a lot of snippets  
though, if you are going to expand them all.

Hope that helps.

James Edward Gray II





More information about the textmate mailing list