9
2
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?
9
2
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?
-1
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.
6
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.
0
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.
I found both answers here somewhat circular. TL;DR
– phs – 2016-12-06T21:47:19.523filetype
is a super-set of the features ofsyntax
. See also this