......或者在任何模式下。
在这种情况下,我只想阻止加载某些扩展,例如:
if ! currentmode('restricted')
Bundle('some-extension')
endif
最佳答案
你是对的;一个特殊的变量,如 v:vimmode
会有所帮助,但我认为目前不存在这样的事情。为什么不在 vim_dev mailing list 上提出这个问题? ?!
同时,您必须通过调用限制模式中禁止的内容的结果来检测模式。我对成功影响最小的最佳想法是调用 writefile()
带有空文件名:
silent! call writefile([], '')
" In restricted mode, this fails with E145: Shell commands not allowed in rvim
" In non-restricted mode, this fails with E482: Can't create file <empty>
let isRestricted = (v:errmsg =~# '^E145:')
关于vim - 如何检测 Vim 是否在受限模式下运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16690202/