1

This VI StackExchange message thread provides useful tips for generating a list of known filetypes. However, I often see Vim modelines use abbreviations like js for javascript. These abbreviated forms (e.g., js) are not shown when I issue a command such as

:setfiletype <Ctrl-d>

to list the known filetypes.

So how do I obtain a list of known/supported abbreviations for filetypes?

5
  • I don't have the impression that these abbreviations are accepted by :setfiletype command. With my configuration :setfiletype set the filetype literally. Is it different for you? What is the result of :setfiletype js and then :set ft?? Aug 29, 2023 at 15:25
  • 3
    No, there is no such thing as "abbreviations for filetypes".
    – romainl
    Aug 29, 2023 at 15:48
  • Okay, thanks for the comments. I sometimes come across webpages and source code with VIM modelines that use abbreviations like 'txt' (which is either a typo, or is intended to be an abbreviation for 'text'), and I got to wondering if maybe the file type strings can be abbreviated a la VIM commands--e.g., set filetype=cpp, or, set ft=cpp Aug 29, 2023 at 18:09
  • 1
    1. txt can be two things: a typo or an actual user-defined filetype. 2. cpp is the filetype.
    – romainl
    Aug 30, 2023 at 5:14
  • Do you still have something open in your question? Otherwise maybe could you accept an answer using the v button next to the arrow voting buttons? It allows the question to rest :-) Sep 6, 2023 at 20:03

1 Answer 1

3

file type abbreviations are not accepted by the :setfiletype command.

The :setfiletype set the filetype literally.

e.g.:

:setfiletype js

Set the filetype to js (:set ft? returns js) which is not equivalent to javascript

1
  • 2
    Indeed javascript and js are two different filetypes, the former being the only valid one in Vim out of the box.
    – romainl
    Aug 29, 2023 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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