vim - ~/.vimrc 如何覆盖 filetype.vim 对语法高亮的错误猜测?

标签 vim glsl vim-syntax-highlighting

GLSL 语法荧光笔 http://www.vim.org/scripts/script.php?script_id=1002效果很好。但它无法识别通常以 #version 330 等行开头的 .frag 或 .vert 着色器文件。 。 (这是在 Ubuntu 12.04.2 LTS 上,一切都是最新的。)

有了这样一行,加载文件后必须手动输入 set syntax=glsl , 可能是因为/usr/share/vim/vim73/filetype.vim 有

" Generic configuration file (check this last, it's just guessing!)

if ... getline(1)=~'^#' ... setf conf .

为什么这没有被 ~/.vimrc 的 au BufNewFile,BufRead *.frag,*.vert setf glsl 否决?有没有一种解决方法可以避免在 filetype.vim 中出现错误?

最佳答案

How can I stop vim from loading a syntax file automatically for certain file types?很接近了。这是解决方法,文件 ~/.vim/filetype.vim:

if exists("did_load_filetypes")
  finish
endif

augroup filetypedetect
  " Override filetypes for certain files
  autocmd! BufNewFile,BufRead *.frag setfiletype glsl
  autocmd! BufNewFile,BufRead *.vert setfiletype glsl
augroup END

关于vim - ~/.vimrc 如何覆盖 filetype.vim 对语法高亮的错误猜测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15976882/

相关文章:

vim - 如何在 Vim 中按 "<C-L> <C-W>l<C-W>_"?

image-processing - 这个 YUV420P 到 RGB 着色器的转换从何而来?

OpenGL 3.3 多纹理 : GL_TEXTURE1 and following are always black (Only GL_TEXTURE0 works fine)

vim - 为什么 vim 中行突出显示不起作用?

python - 在 Vimscript 中,是否可以访问语法荧光笔已知的信息?

vim - Vim 中 .gitignore 的语法高亮显示?

vim - 对 vim 配置警告进行故障排除

vim - 如何在 Vim 中快速上下(ctrl u 和 ctrl d)重新映射到 ctrl j 和 ctrl k

vim - vim 中类型推断的 ctags 跳转可能吗?

opengl - 我是否应该在统一缓冲区或着色器存储缓冲区对象内使用 `vec3`?