【问题标题】:How do I prevent my vim autocmd from running in the command-line window?如何防止我的 vim autocmd 在命令行窗口中运行?
【发布时间】:2012-07-28 19:44:47
【问题描述】:

当我离开插入模式时,我使用自动命令关闭预览窗口,如this answer 中所述。但是当我在命令行窗口(@98​​7654322@)中时,我得到一个错误:E11: Invalid in the command-line window; <CR> executes, CTRL-C quits: :pclose|endif

如何防止出现此错误?

我尝试在命令行窗口和常规窗口中运行:set,但没有明显的选项在差异中显示出来。

【问题讨论】:

    标签: vim


    【解决方案1】:

    使用silent! 抑制错误:

    autocmd CursorMovedI *  if pumvisible() == 0|silent! pclose|endif
    autocmd InsertLeave * if pumvisible() == 0|silent! pclose|endif
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多