What's the difference between `syntax` and `filetype` in Vim?

What's the difference between syntax and filetype in Vim?

I learned that I can set syntax and filetype, but I can't understand the difference fully.

Is syntax used only for syntax highlighting?


Solution 1:

filetype affects more things than syntax (for example: syntax highlighting, indenting rules, and other plugins). So generally, you should use filetype unless you only want to change the syntax highlighting.

http://vim.wikia.com/wiki/Filetype.vim