当我在.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:
打开命令行窗口时,它会产生错误(打开我键入的所有先前命令):
如何解决此问题,并确保不会发生此错误?
command-line-window
中不允许使用某些命令; command-line-window
对此进行了解释。
要在:help E11
中处理此问题,有几种选择:
:help E11
前面加上:autocmd
来抑制任何错误:silent!
... :mkview
包围电话,只是有选择地忽略此错误,但报告其他任何信息:try
条件下添加对命令行窗口的检查;在最新的Vim版本中,您可以使用catch /^E11:/
;它在其他窗口中返回空字符串;有关也适用于旧版Vim的检查,请参见我的:if
中的getcmdwintype()