从.vimrc运行时,vim无法打开文件,但是从终端运行时,vim可以很好地打开文件

时间:2018-09-01 07:52:24

标签: vim

每当我尝试使用Vim打开任何文件时,我都会收到以下错误消息:

Error detected while processing /home/emma/.vimrc:
line  138:
E484: Can't open file '/home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim'
Press ENTER or type command to continue

但是奇怪的是,当我这样做时,文件实际上打开了:

vim ~/.opam/system/share/ocp-indent/vim/indent/ocaml.vim

因此,我已经确认该文件确实存在,并且Vim能够显示代码。

这是我的.vimrc末尾的第120行: enter image description here

这是~/.opam/system/share/ocp-indent/vim/indent/ocaml.vim的全部: enter image description here

1 个答案:

答案 0 :(得分:3)

当vim说

E484: Can't open file '/home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim'

它的字面意思是一个名为'/home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim'(不是/home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim)的文件。

换句话说,问题在于您在文件名周围添加了引号。

修复:

  source /home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim

此外,您可以在此处使用~

  source ~/.opam/system/share/ocp-indent/vim/indent/ocaml.vim