I just discovered that vim defaults modeline to off when executed as root.

What is the reason for this?

1 Answer 1


That is for security reasons. In the past, there have been a couple of vulnerabilities that resulted in e.g. arbitrary code execution. Also you might not want to have certain options set

So one of the measures against it was to disallow modelines for the super user. Another measure was that only certain safe considered options can be set. Options that take an expression are generally not allowed to be set via modelines as this would result in having arbitrary vim code executed while reading a file.


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.