How to make my vim recognize filetype and load the corresponding syntax file

0

Currently, I load my syntax manually in vim by :set filetype=python. Depending on what kind of file I'm working on, I change it manually. I think there should be a more smarter way. Probably some lines to be placed in my .vimrc file

Solution: I had all the standard lines such as:

syntax on
filetype plugin indent on

but the problem is actually the filetype not being recognized, I noticed that I needed a ftplugin.vim at my $VIMRUNTIME and this solves my problem.

Thanks for the help.

Nicholas TJ

Posted 2013-07-16T08:42:37.283

Reputation:

I don't use graphical vim, what does ftplugin.vim do? I mean, it looks like it handles the filetypes... but that's just a guess. – icedwater – 2013-07-16T09:10:09.477

1There's no way this file would be missing from even the most basic installation. That's a problem in and of itself so you should ask another question and explain carefully where things are and how they ended up there. – romainl – 2013-07-16T09:17:33.130

Answers

2

Try adding to your .vimrc;

syntax on
filetype plugin indent on

If you're using Vundle or Pathogen, make sure you add these lines after they are finished. See :help syntax and :help filetype for more information.

Sam Nicholls

Posted 2013-07-16T08:42:37.283

Reputation: 136

I had these commands in my .vimrc but it did not helped. I'll update my problem and solution on my post. – None – 2013-07-16T08:56:36.490

your answer and romaini are the best. I'll just pick this. But the problem I had was the missing ftplugin.vim, but anyway, still a good answer – None – 2013-07-16T09:03:33.293

0

Most files are recognised if you write syntax on in your .vimrc.

icedwater

Posted 2013-07-16T08:42:37.283

Reputation: 115

2I had that but it did not helped. I found out my problem. Will update on my asnwer. – None – 2013-07-16T08:55:51.563

I would make sure it is near the top. Also, it seems to be possible if I set foldmethod=syntax without syntax on, maybe some implicit setting is going on there. – icedwater – 2013-07-16T08:58:35.250

yeah, i think i should delete this. – None – 2013-07-16T09:00:01.663

0

Place these two lines at the top of your ~/.vimrc:

filetype plugin indent on
syntax on

and read :help :filetype and :help syntax.

romainl

Posted 2013-07-16T08:42:37.283

Reputation: 19 227

:help :syntax just shows a little about the command itself. The help section has a whole chapter on syntax highlighting if you call :help syntax. – None – 2013-07-16T08:50:34.607