Reputation: 87
For legacy reasons I'm stuck delimiting PHP code blocks via:
<script language="PHP">
as opposed to:
<?php
This is a valid way of opening a PHP block (see "Escaping from HTML on php.net"); the only problem is, that VIM interprets this as JavaScript, forcing me to execute :set ft=php
each time, if I want it to highlight and indent my code according to PHP specific rules.
I could map :set ft=php
to a shortcut but that's still rather inconvenient. Does anyone know of a way to automate this?
Thanks!
Upvotes: 1
Views: 456
Reputation: 196546
Both scripts allow you to select a "region" of code, edit it in another window with whatever filetype you want and save it back to its original location.
Upvotes: 2
Reputation: 31050
If you want to just automate the file to the php filetype you can do au FileType html set ft=php
if :set ft?
shows html. Or you can do it by extension like au BufRead,BufNewFile *.htm set ft=php
Also, read this: Different syntax highlighting within regions of a file
Upvotes: 1