Posts Tagged ‘syntax highlighting’

Force vim to use specific file type

Tuesday, September 27th, 2011

I recently download the glsl syntax highlighting plugin for vim. It perfectly recognizes my .vert and .frag files. But as soon as I added the line:


#version 120

vim starting thinking the filetype was not glsl but conf.

The cause seems to be that the glsl plugin suggests a rather weak form of recognizing the filetype. Adding the following to your .vimrc file


au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl setf glsl 

When instead to override whatever vim is doing to think that the file is conf you must use the only slightly different


au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl set filetype=glsl

Vim sometimes only partially syntax-highlighting for .tex files

Thursday, May 12th, 2011

Editting .tex files with vim I noticed that sometimes I got full syntax highlighting, but other times only certain keywords were markes and the colors were a bit different. Turns out this was because vim was occasionally recognizing files (based on keywords) as plaintex rather than tex. You can see what filetype vim thinks you have open by issuing:


:set ft

For a bit I was fixing this on a case-by-case basis, if vim’s highlighting was wrong I would issue:


:set ft=tex

and that would fix it for at least the current file and session.

The real permanent fix was to add the following to my ~/.vimrc file:


let g:tex_flavor = "latex"

Now all my .tex files are recognized as tex and not plaintex.