Filetype detection not working

4

1

I am using the same vimrc on two seperate computers, both macbooks using (MacVim). One detects the filetype correctly after launching a file from the terminal. The other makes me manually type.

:set filetype=php

Any other curious observations of what settings in vimrc controls this behavior would be appreciated.

joe-bbb

Posted 2009-11-09T22:42:35.050

Reputation:

By the way, it doesnt matter which filetype I need. The same thing happens for any file. – None – 2009-11-09T22:43:18.060

I take it you've solved the problem by upgrading MacVim? – Joseph Holsten – 2009-11-10T15:38:37.383

Answers

8

try add a line: filetype off before filetype plugin indent on

xps

Posted 2009-11-09T22:42:35.050

Reputation: 81

You saved the day. Thank you. Btw, do you know why is that?, why do I need explicitly off, then on. – user14416 – 2015-08-03T18:44:16.627

3

First thing I would check - On the broken machine, edit your vimrc and make sure set filetype on is in there somewhere.

Other things to check on the broken machine:

  1. $VIMRUNTIME/filetype.vim exists
  2. What does :filetype display when your are editing a file? (Should say that detection plugin & indent are all ON.)
  3. Does set syntax off appear in your vimrc anywhere?

A few things from looking at your file:

Lines 70-72:

The file types are also used for syntax highlighting. If the :syntax on command is used, the file type detection is installed too. There is no need to do :filetype on after :syntax on.

If you are going to use filetype plugin indent on, then you don't need filetype on right before it. This is how the various commands work:

command                      detection   plugin       indent ~  
:filetype on                 on          unchanged    unchanged  
:filetype off                off         unchanged    unchanged  
:filetype plugin on          on          on           unchanged  
:filetype plugin off         unchanged   off          unchanged  
:filetype indent on          on          unchanged    on  
:filetype indent off         unchanged   unchanged    off  
:filetype plugin indent on   on          on           on  
:filetype plugin indent off  unchanged   off          off  

Line 170: Turn off NERD shutup. Do you get any use filetype complaints?

Other thoughts:

Is it possible the file on the non-working machine has a modified filetypes.vim? Diff the files. Are they exactly the same? Are the permissions the same?

DaveParillo

Posted 2009-11-09T22:42:35.050

Reputation: 13 402

>

  • Yes
  • filetype detection:ON plugin:ON indent: ON
  • No
  • < – None – 2009-11-10T11:46:29.633

    0

    Recent versions of vim don't perform filetype detection automatically on startup, because you might set commands in your .vimrc that affect filetype detection.

    Put the following code at the end of your .vimrc, and you'll get filetype detection again

    filetype on
    filetype plugin on
    filetype indent on
    

    Ken Bloom

    Posted 2009-11-09T22:42:35.050

    Reputation: 489

    unfortunately this did not work – None – 2009-11-10T11:41:20.220

    0

    Few things. Since on one of those two your vimrc "works", it means the problem is in the other (I assume on the first one, everything is working satisfactory).

    Vim can load config files from various directories which have different priorities of loading (one overwrites the other). See ":help vimfiles" to see which ones are those.

    Second, try ":echo $myvimrc" to see from where your "latest" vimrc is being loaded from. Is it the one you're currently linking to ?

    Third, as Dave already pointed, do you have a file in your vim directory, called "filetype.vim", and do you have an adequate filetype file ?

    If none of these work out for you, do please also let us know which version of vim/gvim are you using

    Rook

    Posted 2009-11-09T22:42:35.050

    Reputation: 21 622

    :echo $myvimrc shows me ~/Users/joe/.vimrc this is what I expected. MacVim Snapshot 47 works fine. MacVim 7.2 stable 1.2 (33.3) does not work fine. Ok I think I should probably update MacVim! Thanks for looking guys. – None – 2009-11-10T11:51:45.160