7

I'm wanting to turn on syntax highlighting in vim using the .exrc file and using the following commands:

syntax on
syntax=html

Every time I open a file I get the following message now:

No Syntax items defined for this buffer

I'm using VIM version 7.3 on OS X 10.10.4

1
  • I don't mind to use .vimrc as well Jul 31, 2015 at 12:40

2 Answers 2

7

Use the following in your ~/.vimrc file:

filetype plugin indent on
syntax on

For more information see:

:h :filetype
:h :syntax
:h filetype
2
  • Error detected while processing /Users/username/.vimrc: line 3: E475: Invalid argument: ident on Jul 31, 2015 at 12:38
  • 2
    You are missing the n in indent. Jul 31, 2015 at 14:33
0

If you’re trying to set 'syntax' manually, you’d need a :set syntax=html. But the simpler way is to just open foo.html and :syntax on. That should trigger a few settings (like filetype=html and syntax=html.

For more info, see Vim’s :help on :syntax, 'filetype', and :autocmd.

1
  • I'm hoping not to have to set it manually. I'd like to include it in .exrc or .vimrc. Is this possible? Jul 31, 2015 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.