Undofile independent of the Vim version

前端 未结 1 1658
[愿得一人]
[愿得一人] 2021-01-27 09:27

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
 se         


        
相关标签:
1条回答
  • 2021-01-27 10:15

    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.

    0 讨论(0)
提交回复
热议问题