Vim can detects the file types from quite well. But under certain situations, such as creating a new file, Vim does not automatically set the file type. How to manually set it?
In side Vim, to set a filetype, set value to the filetype variable. For example, to set the filetype to php: