Thanks to VanLaser, I was able to implement this with the three vimScript functions string, writefileand readfile(better than source). It is not binary, but it works well :)
function! SaveVariable(var, file)
call writefile([string(a:var)], a:file)
endfun
function! ReadVariable(file)
let recover = readfile(a:file)[0]
" it is so far just a string, make it what it should be:
execute "let result = " . recover
return result
endfun
Use it as follows:
call SaveVariable(anyvar, "safe.vimData")
let restore = ReadVariable("safe.vimData")
Thank!
source
share