简体   繁体   中英

vim cannot open file when run from .vimrc, but can open fine when run from terminal

Whenever I try to open any file with Vim I get this error message:

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

But the strange thing is that when I do this, the file actually opens:

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

So I've verified that the file does exist and that Vim is capable of displaying the code.

Here are lines 120 to the end of my .vimrc : 在此处输入图片说明

And here is the entirety of ~/.opam/system/share/ocp-indent/vim/indent/ocaml.vim : 在此处输入图片说明

When vim says

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

it literally means a file called '/home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim' (not /home/emma/.opam/system/share/ocp-indent/vim/indent/ocaml.vim ).

In other words, the problem is the quotes you added around the filename.

Fix:

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

Also, you could use ~ there:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM