Can't open syntax.vim error when using vimrc
Solution 1
Your server is trying to use a file for lexical highlighting. The file does not exist at the place where vim is looking for it.
At this point, you can do any one of the following:
- Remove the reference to syntax in /etc/vimrc
- Look for the syntax file on your server (e.g.
find / -name syntax.vim
) and copy or symlink that file to the directory where vim is looking - download a syntax file, e.g. from vim.org
- create a syntax file - there's documentation at vimdoc.sourceforge.net
Solution 2
Vim expects to find its installation files (eg help system, definitions for syntax highlighting) in a particular place but can run without many of them. It's possible that while you can run Vim, it cannot locate these installation files.
Vim will try several methods to locate these files but if you have a unusual installation then they won't be found.
If you can access the help system, read these topics: :help $VIM
and :help $VIMRUNTIME
. You'll likely not find them with your current configuration, therefore read versions on the Web, eg :help $VIM and :help $VIMRUNTIME.
I suspect that you can solve your problem by correctly setting one or both of the VIM and VIMRUNTIME environment variables.
You might discover that the vim
binary and runtime files exist in disparate directory trees and that you'll need to hunt for the runtime files below some path, eg: find /path -type d -name 'vim[0-9]*'
An Example
I rely on a Vim instance that is bundled with the Sun Studio development package, which our SysAdmin has provided via a remote mount. The vim
binary is located at /remote/sunstudio12/SUNWspro/contrib/vim/bin/vim
(eg which vim
) and the runtime files are located in /remote/sunstudio12/SUNWspro/contrib/vim/share/vim/vim63
.
I had a similar problem to yours. Firstly, I tried exporting VIM=/remote/sunstudio12/SUNWspro/contrib/vim
, but that didn't work. Separately, I tried exporting VIMRUNTIME=/remote/sunstudio12/SUNWspro/contrib/vim/share/vim/vim63
, which works correctly (while VIM remains unset). VIMRUNTIME
should point to a directory containing files such as menu.vim
, scripts.vim
and directories such as colors
, doc
, syntax
etc (possibly version-dependant, YMMV).
I also modified my PATH
to locate the vim
binary, however, you can successfully run the binary already.
(Updated...)
I revisited my shell environment settings for the above, and found that exporting VIM=/remote/sunstudio12/SUNWspro/contrib/vim/share/vim
(and unsetting VIMRUNTIME
) also worked -- my initial experiments with setting VIM
were misguided. The location pointed to by VIM
contains a directory, vim63
, containing the run-time files that I need.
I still rely on PATH
to locate the vim
binary.
Related videos on Youtube
devsda
Updated on September 18, 2022Comments
-
devsda over 1 year
When I try to open my
.bashrc
file. then it shows these lines:Errordetected while processing /etc/vimrc: line 45: E848: Can't open file /usr/share/vim/vim70/syntax/syntax.vim Press ENTER or type command to continue
When I go to the
/etc/vimrc
file , it showssyntax on
line 45. I've installed the OS three times and it always shows the same error.-
radouxju about 11 yearsWould be nice to see the whole .vimrc. Can you make a gist or a pastebin?
-