Skip to content

Instantly share code, notes, and snippets.

@Guaidaodl
Last active August 12, 2016 05:27
Show Gist options
  • Save Guaidaodl/7ea028598d75faee5c280e5fa865fbfd to your computer and use it in GitHub Desktop.
Save Guaidaodl/7ea028598d75faee5c280e5fa865fbfd to your computer and use it in GitHub Desktop.
将3个空格缩进的文件转换成4个空格的文件. 3个空格真的是异端啊.
#!/usr/bin/ruby
# 将用三个空格缩进的变成四个空格缩进
file_name = ARGV[0]
lines = File.read(file_name)
lines.split("\n").each do |line|
sp_count = 0
while line[count] == " " do
sp_count = count + 1
end
tab_count = sp_count / 3
for c in 1..tab_count
print " "
end
print line + "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment