modeline does not work in vim
That should work. I tried that line myself and it worked. I could be that your 'modeline' option got set to 'nomodeline'. Try executing this and see what you get.
:verbose set modeline?
That will tell you the value of the 'modeline' option and if not the default, where it was last set.
Some Linux distributions set 'nomodeline' in /etc/vimrc or /usr/share/vim/vimrc as a security measure, even though the security problems with 'modeline' have long been fixed.
I describe a full debug checklist in this other answer.
I was REALLY stumped on this one because the documentation is not entirely true.
It turns out that in version 8 (and maybe earlier) you cannot use the word set
in your modeline. The documentation describes "the second form" as being /* vim: set ai tw=75: */
but this does not work. You have to use "the first form" // vim: ai tw=75
Note: You can use either of those kinds of comment indicators. Or none at all.
set modelines=1
(or any non-0 value) in my ~/.vimrc got it working for me.