0

I'm using the Vim 7.3 feature undofile the following way:

if version >= 703
 set undofile
 set undodir=$HOME/.vim/undo
 set undolevels=1000
 set undoreload=10000
endif

I am using the same .vimrc and the same files (within a cloud storage) on different machines which do not support Vim 7.3 but use the old 7.2 version which does not support undofile out of box. Is there a solution for the 7.2 version compatible with the 7.3 undofile?

David Maust
  • 8,080
  • 3
  • 32
  • 36
Joachim
  • 3,210
  • 4
  • 28
  • 43
  • Your snippet will set all those options only in 7.3+ and not in older versions. It looks perfect to me. What exactly are you asking for? How to implement undofile in 7.2? – romainl Apr 25 '13 at 20:48
  • Yes and it would be perfect if the implementations where compatible. – Joachim Apr 25 '13 at 20:52
  • Well, vim.org is where you are supposed to go if you want a plugin. Did you try it before asking here? – romainl Apr 25 '13 at 20:55
  • http://www.vim.org/scripts/script.php?script_id=3198 requires 7.3 – Joachim Apr 25 '13 at 21:09

1 Answers1

4

version check

Because persistent undo was introduced with Vim 7.3, your version check is fine, and prevents errors in older Vims. Usually, you would check for the feature itself; :help 'undofile' has this note:

{only when compiled with the |+persistent_undo| feature}

So the correct check (that also handles Vim 7.3 versions that were explicitly compiled without the feature) would be:

:if has('persistent_undo')

persistent undo for Vim 7.2

The reason that persistent undo has been implemented in core Vim is that this would be very difficult or even impossible to do in a plugin. Therefore, I know of no plugin that back-ports this functionality to Vim 7.2; I also don't see any motivation for such an endeavor, because the feature is non-essential and the solution is so simple: just upgrade to the latest Vim. If you have to administrative rights to install Vim on the system, you could compile or copy a user-local installation of Vim into your home directory.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Thnaks for your answer. I tryed using a locally installed vim. But it is unstable and crashes from time to time. Seems like I have to investigate that further. – Joachim Apr 26 '13 at 10:24