Undofile 独立于 Vim 版本 [英] Undofile independent of the Vim version

查看:29
本文介绍了Undofile 独立于 Vim 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Vim 7.3 功能 undofile 以下方式:

if version >= 703设置撤销文件设置 undodir=$HOME/.vim/undo设置撤销级别=1000设置撤销加载=10000万一

我在不支持 Vim 7.3 的不同机器上使用相同的 .vimrc 和相同的文件(在云存储中),但使用不支持开箱即用的撤销文件的旧 7.2 版本.7.2 版本兼容 7.3 undofile 有解决方案吗?

解决方案

版本检查

因为 Vim 7.3 引入了持久性撤消,所以您的版本检查很好,并且可以防止旧 Vim 中的错误.通常,您会检查功能本身;:help 'undofile' 有这个注释:

<块引用>

{仅当使用 |+persistent_undo 编译时|特征}

因此,正确的检查(也处理在没有该功能的情况下显式编译的 Vim 7.3 版本)将是:

:if has('persistent_undo')

Vim 7.2 的持久撤销

在核心 Vim 中实现持久撤消的原因是,这在插件中很难甚至不可能做到.因此,我知道没有插件可以将此功能反向移植到 Vim 7.2;我也没有看到这种努力的任何动机,因为该功能不是必需的,而解决方案非常简单:只需升级到最新的 Vim.如果您拥有在系统上安装 Vim 的管理权限,您可以编译或复制 Vim 的用户本地安装到您的主目录.

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?

解决方案

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.

这篇关于Undofile 独立于 Vim 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆