tags:

views:

56

answers:

2

I am working on a project writing a GLSL fragment shader, and it just so happens it has the file extension .fs, thus vim automatically loads the forth syntax upon opening the file.

This normally would be no problem, I could just change the syntax using au BufRead but for some reason the forth syntax is loaded first, which completely messes things up. It adds more characters to a "word" which causes syntax highlighting and motions to not work as expected.

Is there a way to stop the forth syntax from loading, and only load my specified syntax?

+3  A: 

Create a file in your .vim directory (or vimfiles directory on Windows) called filetype.vim and put this code in it:

if exists("did_load_filetypes")
    finish
endif

augroup filetypedetect

    " Ignore filetypes for *.fs files
    autocmd! BufNewFile,BufRead *.fs  setfiletype ignored

augroup END

This places a custom filetype-detection script ahead of Vim's default filetype autocommands, so your detection autocommands get a chance to determine the filetype before the usual Vim scripts.

Once you restart Vim and attempt to load a .fs file, it should no longer use Forth syntax highlighting, and iskeyword should still be set to the default value. (If you've installed a syntax file for the GLSL fragment files, you can replace the ignored with the appropriate filetype name.)

See these topics for more info:

:help remove-filetype
:help new-filetype
:help :setfiletype
Bill Odom
Thanks, this works great.
leafo
A: 

Add the following line to the end of your syntax file:

let b:current_syntax = "<filetype>"
too much php