Hello,
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.
Thank you very much for any hint ... Mojca
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. http://www.riemer.com
Phone: 440-835-2477 x. 125 Fax: 440-835-4594 -------------------------------------
On Mon, Jan 24, 2011 at 17:07, Dana Kashubeck dana.kashubeck@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 converters.
Thank you, Mojca