Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Syntax file not loaded automatically

My ~/.vimrc contains the following line:

au BufNewFile,BufRead *.fsh,*.vsh setf glsl

My ~/.vim/syntax directory contains glsl.vim that works if loaded manually (:setf glsl in Vim), but it doesn't load automatically when editing a file with those extensions. How do I get syntax highlighting for those files automatically? Syntax highlighting works for other files as usual. My Vim version is 7.4 running on Linux Mint.

like image 474
SurvivalMachine Avatar asked Jan 29 '14 18:01

SurvivalMachine


People also ask

How do I permanently set syntax in Vim?

Add the text, “syntax on” anywhere in the file to enable syntax highlighting permanently for vim editor. Save and close the file by typing ':x'. For disabling the feature, just re-open . vimrc file, change the text “syntax on” to “syntax off” and save the file.

Where does Vim put syntax files?

Install the syntax file. Save the file, then install it by copying the file to ~/. vim/syntax/cel. vim on Unix-based systems, or to $HOME/vimfiles/syntax/cel.

How do I enable syntax highlighting in vim Mac?

If you want to toggle this on/off (without creating a . vimrc file) simply type :syntax on while in vi/vim. Save this answer.


1 Answers

I don't think that line can be in your ~/.vimrc. Due to loading order, it may have to be in ~/.vim/filetype.vim instead. Try putting this into that file:

augroup filetypedetect
  au BufNewFile,BufRead *.fsh,*.vsh setf glsl
augroup END
like image 86
Adam Katz Avatar answered Oct 07 '22 00:10

Adam Katz