1

I am working on a codebase that uses php within .html files. How do I tell VIM to highlight php correctly in .html files without renaming all of my .html to .php?

4 Answers 4

6

Alec led me in the right direction as to what to look for, but I was looking for a hardcoded solution in the vimrc file. I went ahead with this:

augroup filetype
        autocmd BufNewFile,BufRead <Directory Path>/*.html set filetype=php
augroup END

This changes all files within the codebase to php for highlighting

Sign up to request clarification or add additional context in comments.

Comments

3

Perhaps with :set filetype?

http://vimdoc.sourceforge.net/htmldoc/usr_06.html

Comments

0

I realize this is an old question, but this worked for me: set ft=php.html

This tells VIM to highlight using the syntax for both filetypes.

Comments

0

Here is a simple solution for your .vimrc file:

:au BufNewFile,BufRead *.html set filetype=php

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.