Skip to content

Instantly share code, notes, and snippets.

@young40
Created March 30, 2017 02:38
Show Gist options
  • Save young40/04f340273c011fd173ba1e40b2469f5c to your computer and use it in GitHub Desktop.
Save young40/04f340273c011fd173ba1e40b2469f5c to your computer and use it in GitHub Desktop.
replace tab with 4 space
local function tab2space(filename)
local lines = {}
io.input(filename)
for line in io.lines() do
table.insert(lines, line)
end
local newLine = {}
for _, line in ipairs(lines) do
line = string.gsub(line, "\t", " ")
-- print(line)
table.insert(newLine, line)
end
local allLine = table.concat(newLine, "\n")
local fp = io.open(filename, "w")
io.output(fp)
io.write(allLine)
io.close(fp)
end
tab2space("PlaySceneGA.lua")
@young40
Copy link
Author

young40 commented Mar 31, 2017

if you'r using OS X, there is a command /usr/bin/tab2space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment