【问题标题】:Vim - load view and mkview errors in command line windowVim - 在命令行窗口中加载视图和 mkview 错误
【发布时间】:2019-11-20 08:33:56
【问题描述】:

当我在我的 .vimrc 中使用这个脚本时:

"Save and restore folds when a file is closed and re-opened
autocmd BufWinEnter                    ?* if(!empty(glob(expand("%:p")))) | silent loadview | endif
autocmd BufWritePost,BufLeave,WinLeave ?* if(!empty(glob(expand("%:p")))) | mkview          | endif

当我通过q: 打开命令行窗口时会产生错误(这会打开我之前输入的所有命令):

我该如何解决这个问题,并确保不会发生此错误?

【问题讨论】:

    标签: vim view command window


    【解决方案1】:

    command-line-window 中不允许某些命令; :help E11 解释了这一点。

    要在您的 :autocmd 中处理此问题,有几种选择:

    • 通过在:mkview 命令前添加:silent! 来抑制任何错误
    • :try ... catch /^E11:/ 包围呼叫以选择性地忽略此错误,但报告其他任何内容
    • :if 条件中添加对命令行窗口的检查;在最近的 Vim 版本中,你可以使用getcmdwintype();它在其他窗口中返回一个空字符串;检查也适用于旧版 Vim,请参阅我的 ingo-library plugin 中的 ingo#compat#window#IsCmdlineWindow()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-20
      • 2012-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多