Can Vim detect filetype of a buffer with contents, but which doesn't have a name yet (not yet saved)? :filetype detect
doesn't do much.
Most filetypes are detected by their file name (and/or location), some (mostly those with a #!
shebang line) by their contents.
If you don't want to save the buffer yet, but have detection, you can name the buffer via :file name.ext
. Then, the detection via :filetype detect
will work.
If you just want syntax highlighting (and corresponding filetype settings) quickly, just manually set the filetype via :setf name
.
You can do this manually.
:set filetype=EXT
Note that EXT is the extension for the filetype you want, not necessarily the name of the language itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With