To change the language/file type (and therefore syntax highlighting and features) on the fly in Vim it's as simple as:


:set filetype=

So for example, for PHP, Java and automatically detecting the language respectively:


:set filetype=php
:set filetype=java
:filetype detect