vim无法打开syntax.vim

时间:2010-09-23 02:51:52

标签: vim

在我的.vimrc我有以下代码段:

if has('autocmd')
    filetype plugin indent on
    syntax on

但是当我启动vim时它显示以下错误:

Can't open file /usr/share/vim/syntax/syntax.vim
<{1}}中的syntax on行似乎发生

错误。

我在路径.vimrc中没有syntax.vim但我有其他人/usr/share/vim/syntax

我搜索但似乎无法找到默认clojure.vim cpp.vim java.vim etc...,如果它带有默认版本的vim。

我已经坚持了一段时间,并希望得到一些帮助。

4 个答案:

答案 0 :(得分:2)

我使用Arch并使用vim-git PKGBUILD从AUR构建vim。对我来说,情况是使用vim-git,但来自官方回购的vim-runtime,而不是来自AUR的vim-runtime-git

切换到vim-runtime-git为我解决了这个问题并提供了语法文件(以及颜色和......)。

答案 1 :(得分:0)

它应该在那里,因此可能缺少其他文件。我建议你重新安装!。

对于QDF,这里是什么 syntax.vim文件应如下所示: -

" Vim syntax support file
" Maintainer:   Bram Moolenaar <Bram@vim.org>
" Last Change:  2001 Sep 04

" This file is used for ":syntax on".
" It installs the autocommands and starts highlighting for all buffers.

if !has("syntax")
  finish
endif

" If Syntax highlighting appears to be on already, turn it off first, so that
" any leftovers are cleared.
if exists("syntax_on") || exists("syntax_manual")
  so <sfile>:p:h/nosyntax.vim
endif

" Load the Syntax autocommands and set the default methods for highlighting.
runtime syntax/synload.vim

" Load the FileType autocommands if not done yet.
if exists("did_load_filetypes")
  let s:did_ft = 1
else
  filetype on
  let s:did_ft = 0
endif

" Set up the connection between FileType and Syntax autocommands.
" This makes the syntax automatically set when the file type is detected.
augroup syntaxset
  au! FileType *    exe "set syntax=" . expand("<amatch>")
augroup END


" Execute the syntax autocommands for the each buffer.
" If the filetype wasn't detected yet, do that now.
" Always do the syntaxset autocommands, for buffers where the 'filetype'
" already was set manually (e.g., help buffers).
doautoall syntaxset FileType
if !s:did_ft
  doautoall filetypedetect BufRead
endif

答案 2 :(得分:0)

升级到7.3后我也遇到了这个问题(我正在使用cygwin)。检查运行“vi”而不是“vim”是否存在同样的问题。我发现vim实际上是旧的7.2可执行文件,但语法文件位于7.3的预期位置; vi是正确的7.3可执行文件。

答案 3 :(得分:0)

我一直在使用源代码编译的 vim,而没有在我的系统上明确安装它(由于缺少 sudo 权限)。

通过将以下行添加到我的 .bashrc 中,我能够解决该问题:

export VIMRUNTIME=<path to cloned vim repo>/runtime

因此:将这个 env 变量指向 git 树中的 runtime 目录,使 vim 找到所需的文件。