vim: keep undo when moving a file?

152 vistas
Ir al primer mensaje no leído

ping song

no leída,
5 jul 2016, 10:29:51 a.m.5/7/2016
para vim-use Mailingliste
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?

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

Eric Christopherson

no leída,
5 jul 2016, 11:32:09 p.m.5/7/2016
para vim...@googlegroups.com
On Tue, Jul 05, 2016, ping song wrote:
> 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?

I would love to see that.

--
Eric Christopherson

Eric Christopherson

no leída,
5 jul 2016, 11:36:22 p.m.5/7/2016
para vim...@googlegroups.com
On Tue, Jul 05, 2016, ping song wrote:
> 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?

I just realized that a plugin I enjoy using, vim-eunuch, does allow the
history to be saved when you move or rename files. It defines a handful
of ex commands for Unix-like file operations; the ones I'm talking about
are of the form

:Rename newname

and

:Move newfolder

(you run those while you have the file open and it moves it in place).

--
Eric Christopherson

Nikolay Aleksandrovich Pavlov

no leída,
6 jul 2016, 4:29:30 p.m.6/7/2016
para vim...@googlegroups.com
2016-07-05 17:29 GMT+03:00 ping song <songpi...@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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos