I did one in Ruby. It works via the command line and you can detab the a list of files that you pass as arguments. You can also specify the tabstops, but by default I used two since I'm partial to that :)
# This would detab the file itself and another file
ruby detab.rb detab.rb /some/other/file.rb
# This would use 4 spaces instead of two
ruby detab.rb --tabstop=4 detab.rb /some/other/file.rb
And the code itself:
if match = ARGV.first.match(/--tabstop=(\d)/)
ARGV.delete_at 0
tabstop = match[1].to_i
else
tabstop = 2
end
SPACES = ' ' * tabstop
def detab(text)
text.gsub(/\t/, SPACES)
end
files = ARGV
for path in files
begin
content = File.read(path)
File.open(path, 'w') do |file|
file.write detab(content)
end
rescue
puts "Could not edit file: #{path}"
end
end