Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

 
discard

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.