Last active
August 12, 2016 05:27
-
-
Save Guaidaodl/7ea028598d75faee5c280e5fa865fbfd to your computer and use it in GitHub Desktop.
将3个空格缩进的文件转换成4个空格的文件. 3个空格真的是异端啊.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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