Override Vim's Filetype

Vim typically does a good job of file type detection for syntax highlighting, indenting, etc. But vim will punt on some file extensions (or lack thereof) for example yaml config files or markdown.

Override the filetype in the buffer:

:set ft=markdown

Set the filetype in the file itself

This can be handy if you don't mind an extra comment line at the top or bottom of your file.

# vi: ft=python

You can also set other options, eg:

# vi: shiftwidth=4

Remember that the comment markup should be in the valid syntax of file's language.