Other VIM modeline not working on version 9.2.461

I've just upgraded all my FreeBSD machines to FreeBSD 15, and one thing I've noticed is that all my modelines are being ignored, on any of my files, from scripts to html files.

I've spent ages now searching the internet and asking LLM's, to no avail, the only thing the LLM keeps mentioning is that there was a security vulnerability found in vim modeline parsing, and that a fix was issued. I can see on https://www.freshports.org/editors/vim/ that there was an update at "9.2.0272" to fix the vulnerability.

However I don't think the fix involved disabling modelines completely? So far even with a completely bare vim config the modelines still do not work.

my vimrc just has:

Code:
set modeline
set modelines=5
set nocompatible


and my test.txt file has the following:

Code:
#!/bin/sh
# vim: set number
This is a modeline test
# comment
$var

It is all rather simple, and I can't figure out why it is not working. Checking ":set modeline?" shows "modeline" and everything else seems to be fine. I tried with vim -u NONE -c "set modeline" ./test.txt with the same result. Anyone seen similar with this version of vim?
 
Not every option can be set via modeline. I am not sure if that's the case with number.

Also opening a file that ends with .txt might load the associated ftplugin. .txt doesn't have comments, so '# vim:' is probably not recognized as '#' has no meaning.

:help modeline
:help ft

Are your friends
 
Not every option can be set via modeline. I am not sure if that's the case with number.
Well that was just an example, and I used it as its the most obvious visually if it works. I seem to remember it working before, but you may be right. In addition to a few other tests I also tried "ts". which is one of the basics that should always work.

However putting # vim: set ts=77: still leaves me with my default ts=8 configured.

The actual vim modeline that made me realise something was amiss was <!-- vim: set syntax=html fenc=utf-8 spell spl=en: -->, when the syntax was not being set to html and "spell" was not set either.

Also opening a file that ends with .txt might load the associated ftplugin. .txt doesn't have comments, so '# vim:' is probably not recognized as '#' has no meaning.
Again just an example. I have tried with no extension, ".sh", ".pl" and other such ones, same result.

However, if I explicitly define the filetype in the modeline, e.g. <!-- vim: set ft=html syntax=html fenc=utf-8 spell spl=en: --> it now works as before. In fact I can just remove syntax=html as setting the filetype automatically sets the correct syntax. Setting # vim: set ft=sh ts=77: in my example above also now works.

I still don't understand why it stopped working though, the original html modeline has worked for me for years now, but if I have to define the actual filetype in the modeline from now on I can live with that.

Thanks!
 
Back
Top