Replies: 3 comments 4 replies
-
You can write a plugin that uses the go_os = import("os")
go_io = import("io")
function preSave(bufpane)
local path = bufpane.Buf.AbsPath
local srcfile, err = go_os.Open(path)
local destfile, err = go_os.Create(path .. "~")
local bytesWritten, err = go_io.Copy(destfile, srcfile)
srcfile:Close()
destfile:Close()
end Note that code above doesn't do any error handling at all so you might want to adjust it a little bit (you might have problems if saving the copy would need permissions). |
Beta Was this translation helpful? Give feedback.
-
Oh, thank you for your quick reply! |
Beta Was this translation helpful? Give feedback.
-
I'm using Andriamanitras suggestion for nearly a year now. I have added some error handling and it worked perfect. |
Beta Was this translation helpful? Give feedback.
-
I had vim configured to keep an old version of files while saving. In my case it is stored with "~" suffix.
Is there any possibility to do this with micro editor?
Thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions