I copied this GLSL syntax file to /usr/share/vim/vim74/syntax/glsl.vim, its permissions are -rw-r--r-- same as other syntax files.

I gvim /tmp/x.glsl but it does not activate GLSL syntax highlighting as I expected.

I go to Syntax > Show fileypes in menu and the full range of recognised languages opens up. There is nothing under "G" for "GLSL", nor is there anything under "O" for "OpenGL".

What do I have to do to make vim notice the new glsl.vim syntax highlighting specification?

1 Answer 1


The Syntax > Show filetypes in menu action sources $VIMRUNTIME/synmenu.vim. If you open that one, you see that

  " The following menu items are generated by makemenu.vim.

So, it seems to be a static thing created during Vim build time. It unfortunately does not pick up added or user-specific syntaxes.

The directory /usr/share/vim/ is managed by your distribution's package manager. If you put files there, they may get lost when you reinstall or upgrade Vim. Don't do that. The straightforward fix is to put it in ~/.vim/syntax/; it then only applies to you. [1]

Vim distinguishes between syntax highlighting and filetypes. For your added syntax to apply, you need to detect GLSL files. :help new-filetype tells you how to do it.

One (modular) way to do this is by creating ~/.vim/ftdetect/glsl.vim with the following contents:

au BufRead,BufNewFile *.glsl        set filetype=glsl

You need :filetype on and :syntax on in your ~/.vimrc, too, but those are very common settings, so you probably have those already.

[1] If you really have a multi-user system and need to make it available system-wide, put it somewhere else on 'runtimepath'. Depending on your distribution, there may already be such a path pre-configured (e.g. in /etc/vim/vimrc on Debian), or the opportunity to source system-specific configuration (e.g. /etc/vim/vimrc.local), and you can augment the 'runtimepath' there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .