[TxMt] Re: Just starting to call myself a full time TM uses, general

Christopher Creutzig christopher at creutzig.de
Thu Apr 30 18:29:11 UTC 2009


Scott Haneda wrote:
> Is there a native way to do brace reformatting?  I believe it is  
> called "cuddling".  I often pull a function from here or there, and  
> the formatting is not to my liking...
> 
> function {
>   # code
> }
> 
> versus
> 
> function
> {
>   # code
> }

 Should be something like

ruby -0777 -p -e '$_.gsub!(/\n\s*{/ {/)'

or, if you really want to go the other way (:-)), you don't need
multi-line matching and can do it right in TextMate, substituting

^(\s*)(\S.*)\s*{\s*$

with

$1$2\n$1{

(I even tested that. It works on your example, which is a start.)


Christopher





More information about the textmate mailing list