Vim-命令行窗口中的加载视图和mkview错误

问题描述 投票:1回答:1

当我在.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:打开命令行窗口时,它会产生错误(打开我键入的所有先前命令):

error image

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

vim view command window
1个回答
2
投票

command-line-window中不允许使用某些命令; command-line-window对此进行了解释。

要在:help E11中处理此问题,有几种选择:

  • 通过在:help E11前面加上:autocmd来抑制任何错误
  • :silent! ... :mkview包围电话,只是有选择地忽略此错误,但报告其他任何信息
  • 在您的:try条件下添加对命令行窗口的检查;在最新的Vim版本中,您可以使用catch /^E11:/;它在其他窗口中返回空字符串;有关也适用于旧版Vim的检查,请参见我的:if中的getcmdwintype()
© www.soinside.com 2019 - 2024. All rights reserved.