代码之家  ›  专栏  ›  技术社区  ›  wheeeee

当从.vimrc运行时,vim无法打开文件,但当从终端运行时,可以正常打开

vim
  •  0
  • wheeeee  · 技术社区  · 7 年前

    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能够显示代码。

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

    ~/.opam/system/share/ocp-indent/vim/indent/ocaml.vim : enter image description here

    1 回复  |  直到 7 年前
        1
  •  7
  •   melpomene    7 年前

    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