[TxMt] Re: replacing tabs with spaces in selected area

Dana Kashubeck dana.kashubeck at riemer.com
Mon Jan 24 16:07:31 UTC 2011

On Jan 24, 2011, at 10:37 AM, Mojca Miklavec wrote:
> I'm looking for a trick that would help me replace tabs by spaces in
> selected area. I have source code that looks approximately like this:
>    <tab><tab>short<tab><tab><tab><tab>a;
>    <tab><tab>unsigned long<tab>b;
>    <tab><tab>int<tab><tab><tab><tab><tab>c;
> which is only aligned when some specific size of tab is chosen. I
> would like to keep the first two tabs (to preserve nice alignment),
> but replace the tabs between "short" and "a", so that the text would
> be aligned under any tabulator width setting.
> I cannot use just "Search & Replace" because the first tab has
> variable width (depending on its starting position).
> If there is no out-of-the-box solution, I know some ruby, so I could
> write a program that would perform the task for me, but I'm not sure
> how to pass the following information from TextMate to my script:
> - at which column does my selection start (I would like to "alt"- 
> select a "box")
> - how wide is the current tab
> But I hope that there exists an easier solution.

Sure!  Just select the text that you want to change, then select Text  
--> Convert --> Tabs to Spaces.

Make sure that your tab width is set to where you want it beforehand.

Dana Kashubeck
Lead Web Developer
Riemer Reporting Service Inc.

Phone: 440-835-2477 x. 125
Fax:   440-835-4594

More information about the textmate mailing list