Added the undofile() function. Updated runtime files.

This commit is contained in:
Bram Moolenaar
2010-05-30 18:30:36 +02:00
parent 504a82173c
commit a17d4c1934
15 changed files with 71 additions and 25 deletions

View File

@ -243,12 +243,26 @@ respectively:
You can use these in autocommands to explicitly specify the name of the
history file. E.g.: >
au BufReadPost * rundo %:h/UNDO/%:t
au BufWritePost * wundo %:h/UNDO/%:t
au BufReadPost * call ReadUndo()
au BufWritePost * call WriteUndo()
func ReadUndo()
if filereadable(expand('%:h'). '/UNDO/' . expand('%:t'))
rundo %:h/UNDO/%:t
endif
endfunc
func WriteUndo()
let dirname = expand('%:h') . '/UNDO'
if !isdirectory(dirname)
call mkdir(dirname)
endif
wundo %:h/UNDO/%:t
endfunc
You should keep 'undofile' off, otherwise you end up with two undo files for
every write.
Note: I did not verify this always works!
You can use the |undofile()| function to find out the file name that Vim would
use.
Note that while reading/writing files and 'undofile' is set most errors will
be silent, unless 'verbose' is set. With :wundo and :rundo you will get more