summaryrefslogtreecommitdiff
path: root/runtime/doc/undo.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-05-30 18:30:36 +0200
committerBram Moolenaar <Bram@vim.org>2010-05-30 18:30:36 +0200
commita17d4c1934b008b9aa8a2d7cf085cfe76a690d9a (patch)
tree0698c081448b50f5c579252f34433da021de4984 /runtime/doc/undo.txt
parent504a82173c607f50801e90f8001bb2f1c13fecf9 (diff)
downloadvim-git-a17d4c1934b008b9aa8a2d7cf085cfe76a690d9a.tar.gz
Added the undofile() function. Updated runtime files.
Diffstat (limited to 'runtime/doc/undo.txt')
-rw-r--r--runtime/doc/undo.txt20
1 files changed, 17 insertions, 3 deletions
diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt
index a7ae1736c..4dbe69394 100644
--- a/runtime/doc/undo.txt
+++ b/runtime/doc/undo.txt
@@ -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