Joachim
Joachim

Reputation: 3270

Undofile independent of the Vim version

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?

Upvotes: 0

Views: 513

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172520

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.

Upvotes: 4

Related Questions