Thursday, December 20, 2007

Vim modelines

Regularly I've wondered why vim modeline settings don't take effect when they're embeded in a file.

Historically modelines have opened up vim to security exploits, so the default is for modeline parsing to be disabled. You can check the status in vim with

:set modeline? modelines?
nomodeline
modelines=0


This is the default setting and can be overridden in your ~/.vimrc file like this

:set modeline modelines=20


Now a modeline appearing in a file will be parsed, so something I find useful for python scripts is:

# vim:ts=4:sw=4:sts=4:expandtab

No comments: