Search code examples
vimfile-type

Forcing multiple file types in Vim


Vim supports multiple file types for the main file formats. But this does not work for less popular formats such as LaTex and grapviz. Try it out for yourself, go here, copy paste the code into vim and try setting the file type to any permutation of .tex and .doc or .gv

Is there a way to inform vim that I am entering a different file type block? Something like

\author{John Smith}
\title{This is LaTex}

\*!setfiletype .gv!*\
digraph G{...}
\*!setfiletype .tex!*\

This is Latex Again

Solution

  • For this, you would need a custom Tex syntax file that includes Graphviz's syntax.

    Both :help syn-include and this question/answer might help.

    Or you may do things in a more straightforward fashion: edit Tex stuff in .tex files and Graphviz stuff in .gv files.