[BioRuby] Code cleanup: expanded tabs into spaces.

Anurag Priyam anurag08priyam at gmail.com
Fri Apr 16 21:38:16 UTC 2010


I think I have got the solution. Vim seems to expand tab nicely; preserves
the indentation as well. So I used "vim -c <command> and "find" together to
do the job. Its a little hackish though.

find . -name "*.rb" -exec vim -c Retab {} ';' #open a file in vim, run
:retab, save and quit

where, Retab command in vim has been defined as:

:command Retab :call Retab_save_quit() "call the function Retab_save_quit()
when, Retab command is invoked

and, retab_save_quit() function was defined as:

function Retab_save_quit()
  retab "retab the file
  wq "save and quit
end

with following options set:
set shiftwidth=2
set softtabstop=2
set expandtab

I disabled my default vimrc to speed up the command, still it took almost
1:40 seconds. It had to go through 422 Ruby files :-|.

I have already disturbed all with a previous pull request :P, so I think I
should wait for comments first.
Here is the new diff:
http://github.com/yeban/bioruby/compare/master...tab_2


On Sat, Apr 17, 2010 at 2:20 AM, Anurag Priyam <anurag08priyam at gmail.com>wrote:

> I think because of the different tab sizes used by everyone, I have got the
> indentation wrong in few files. Replacing tabs at the beginning of the lines
> also does not work( infact, it destroys indentation in every file). Vim's
> :retab command seems to work properly though. Please could someone point me
> in the right direction?
>
>
> On Sat, Apr 17, 2010 at 1:59 AM, Anurag Priyam <anurag08priyam at gmail.com>wrote:
>
>> I am unsure if it is needed or not. A simple combination of find and sed
>> did the job.
>>
>> Here is the one liner that I used:
>> find . -name '*.rb' -exec sed -i 's/\t/        /g' {} ';'
>>
>> A patch would have been too long, so I have sent a pull request on github
>> for review.
>>
>> Diff:
>> http://github.com/yeban/bioruby/compare/master...tab
>>
>> --
>> Anurag Priyam
>> 2nd Year,Mechanical Engineering,
>> IIT Kharagpur.
>> +91-9775550642
>>
>
>
>
> --
> Anurag Priyam
> 2nd Year,Mechanical Engineering,
> IIT Kharagpur.
> +91-9775550642
>



-- 
Anurag Priyam
2nd Year,Mechanical Engineering,
IIT Kharagpur.
+91-9775550642



More information about the BioRuby mailing list