0

I have been leaving my script open in VIM in one PuTTY session and then testing it in another session after writing. That way if my changes break something, I still have my undo history.

Is there any way to get persistent undo without upgrading to VIM 7.3?

It looks like you can use

    :set hidden

to save it when switching buffers, but saving your undo history after exiting VIM isn't build in until 7.3. Anyone know of a simple workaround?

hmatt1
  • 4,939
  • 3
  • 30
  • 51
  • 1
    You should specify your vim version. It seems you are not using 7.3. Is this correct? – FDinoff Jul 08 '13 at 03:16
  • I am using a earlier version, I can't look it up until tomorrow though I think it's 7.1 or 7.2. – hmatt1 Jul 08 '13 at 03:19
  • 1
    Use a terminal multiplexer (e.g. tmux, screen). Use a version control system (e.g. git, mercurial). – 1983 Jul 08 '13 at 03:23
  • I am going to guess that there is no way other than to upgrade (Ingo Karkat seems to believe this http://stackoverflow.com/questions/16224228/vim-undofile-indepentdent-of-the-vim-version). Is there any reason you can't upgrade. – FDinoff Jul 08 '13 at 03:24
  • use backups and save only once per-edit. Or leave a commented out version of the original portions of the edited code until you are sure you don't need it anymore. – perreal Jul 08 '13 at 03:42
  • I'll take Karkat's word for it. I might be able to upgrade but I'm not always on the same machine, I'll look into it. I wasn't using screen because you can't split vertically (unless you patch it), and even then I like being able to move things between monitors and resize to different sizes often. Thanks for the suggestions! – hmatt1 Jul 08 '13 at 04:19
  • You can split vertically in tmux. You can also still have more than one Putty window open. A good thing with tmux/screen is that you can *detach* your session. So when you reattach again you'd still have your undo history since you won't have closed vim. – 1983 Jul 08 '13 at 04:32
  • 2
    @perreal If you use a version control system then you don't need to limit yourself like that. – 1983 Jul 08 '13 at 04:34
  • You should consider using git or mercurial. What you're doing sounds a bit of a roundabout solution to version control. – d11wtq Jul 08 '13 at 07:34

2 Answers2

2

You can't. Vims persistent undo was introduced with version 7.3. There exists an unofficial patch to make use of persistent undo using vim 7.2, but several bugs in persistent undo mode have been fixed since the release of vim 7.3

Christian Brabandt
  • 8,038
  • 1
  • 28
  • 32
  • Thanks! I ended up downloading the 7.3 VIM source and compiling it, and setting an alias to use it. I also have it set up to automatically save and load my undo history upon entry/exit. It takes a little longer to load though so I still want the old vim as an option. – hmatt1 Jul 09 '13 at 20:12
0

You can either use a multiplexer like screen or tmux which is a good idea for all sorts of reasons or you can simply stop quitting vim:

  1. Make and save your changes
  2. Press ctrl-z
  3. Test the changes you made
  4. Enter fg on the shell prompt to get back to your vim session.
innaM
  • 47,505
  • 4
  • 67
  • 87