Wednesday, July 6, 2016

Re: vim: keep undo when moving a file?

2016-07-05 17:29 GMT+03:00 ping song <songpingemail@gmail.com>:
> I have a file that I keep using for quite a long while, it's convenient to
> keep the editing history forever, so if something gone wrong I can always
> undo back and locate the issue.
>
> today I moved the file to another folder and all undo history gone.
> I tried to rename my original undo file according to the new location , but
> still not work...
> anyone has a good solution?

If I am not mistaking to move file A to location B keeping undo
history you need to

:saveas B
:bwipeout! A
:call delete('A')

I.e. copy file to the new location by saving it there (creates new
buffer), drop old buffer and delete leftover copy of the file at the
new location. Plugin that was referenced by @Eric Christopherson does
something like this, but it also seems to cover some corner cases.

>
> this is my undo related config in .vimrc , I'm running latest vim 7.4..
>
> set udf
> if exists("+undofile")
> " undofile - This allows you to use undos after exiting and restarting
> " This, like swap and backups, uses .vim-undo first, then ~/.vim/undo
> " :help undo-persistence
> " This is only present in 7.3+
> if isdirectory($HOME . '/.vim/undo') == 0
> :silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
> endif
> set undodir=./.vim-undo//
> set undodir+=~/.vim/undo//
> set undofile
> " set undolevels=1000 " maximum number of changes that can be
> undone
> set undoreload=10000 " maximum number lines to save for undo on a
> buffer reload
> endif
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: