make replaceword safer
This commit is contained in:
@ -14,9 +14,12 @@ end
|
|||||||
function M.replaceword(old, new)
|
function M.replaceword(old, new)
|
||||||
local conf = vim.fn.stdpath("config").."/lua/conf/".."opts.lua"
|
local conf = vim.fn.stdpath("config").."/lua/conf/".."opts.lua"
|
||||||
local f = io.open(conf, "r")
|
local f = io.open(conf, "r")
|
||||||
|
if not f then return end
|
||||||
local new_content = f:read("*all"):gsub(old, new)
|
local new_content = f:read("*all"):gsub(old, new)
|
||||||
|
f:close()
|
||||||
|
|
||||||
f = io.open(conf, "w")
|
f = io.open(conf, "w")
|
||||||
|
if not f then return end
|
||||||
f:write(new_content)
|
f:write(new_content)
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user