Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 0 down vote accepted

It will expect certain filetypes to have a specific syntax. For example when you open a file.php it will expect a PHP syntax and colour it accordingly.

But some people use unusual filetypes but still want to use the correect syntax in the editor, for example file.txt or file.bla with PHP content inside.

Syntax is the "language" inside the file, where filetype is the actual type of the file.

share|improve this answer

a c-file is a c-file (filetype), no matter how you color the different elements of the file (syntax). some decisions (for example, how to color some words, where to put brackets etc) are maded based upon the filetype.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.