Does anyone know of a way to get vim to guess the programming language of a new file based on your input and use the appropriate syntax highlighting? So far the syntax highlighting only works when it knows the file extension (after I have saved it), which is good, but sometimes I am lazy and want to make a new file without saving it until later.
e.g. if I were to start a new file and type:
#include <stdlib.h>
I would like it to automatically start using C syntax highlighting, say after I hit enter, and the same goes for other languages like Python.
I am a bit of a noob with vim and don't know vimscript, so don't make it too complicated please. Any help is appreciated.
Thanks, Simon