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?
Create a file in your
.vimdirectory (orvimfilesdirectory on Windows) calledfiletype.vimand put this code in it: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
.fsfile, it should no longer use Forth syntax highlighting, andiskeywordshould still be set to the default value. (If you’ve installed a syntax file for the GLSL fragment files, you can replace theignoredwith the appropriate filetype name.)See these topics for more info: