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

Mojca Miklavec mojca.miklavec.lists at gmail.com
Tue Jan 25 11:01:06 UTC 2011

On Mon, Jan 24, 2011 at 17:07, Dana Kashubeck <dana.kashubeck at riemer.com> wrote:
> 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.

Thanks a lot, it was simply too trivial to be true :)

I was looking into Bundles -> Text -> Convert ... and there were other

Thank you,

More information about the textmate mailing list