Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file called .aliases for bash and zsh, I put this line

# vim: set filetype=bash: 

but if I make

: echo &ft

I get conf

share|improve this question

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.

share|improve this answer
modeline Last set from ~/.vimrc – juanpablo Aug 16 '11 at 5:06
for security, I change the modeline to add this to my ~/.vimrc au BufNewFile,BufRead .*aliases set filetype=sh – juanpablo Aug 16 '11 at 5:24

set modelines=1 (or any non-0 value) in my ~/.vimrc got it working for me.

share|improve this answer
This has no effect if modeline is not also set (which it is by default in Vim unless you're root) – kynan Sep 5 '13 at 12:10
Gentoo has a system-wide set nomodeline in /etc/vimrc due to all the vulnerabilities with modelines handling in vim. – MattBianco May 23 '14 at 13:43
In my case, I also had to set modelines to a non-zero value. The help says the default is 5, so that's what I set it to and that did the trick for me. The states that, If 'modeline' is on 'modelines' gives the number of lines that is checked for set commands. If 'modeline' is off or 'modelines' is zero no lines are checked. – Ben Jun 10 at 15:59

in ~/.vimrc you need to set following:

set nocompatible 
filetype plugin on
set modeline 
share|improve this answer

Adding just the following to my ~/.vimrc worked for me on my Funtoo Linux box:

set modeline
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .