Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any "code corrector" for Vim which highlights HTML, PHP, CSS mistakes?

Tags:

html

css

php

vim

Sometimes when I make coding mistakes I spend a lot of time finding the error.

Is there a plugin which makes Vim underline or highlight PHP, HTML or CSS mistakes?

For instance:

 <?php
 foreach ($row as $r) {
  <echo '<h1>' . $r->title . '</h1>';
 }
 ?>

The '<' before echo will be highlighted in red.

Vim has HTML correction but I need for PHP and CSS.

like image 484
alexchenco Avatar asked Aug 06 '10 05:08

alexchenco


2 Answers

There is plugin for Vim, developed by the infamous scrooloose, called Syntastic that does exactly what you are looking for. It is described as:

A syntax checking plugin that runs buffers through external syntax checkers as they are saved and opened. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them.

The syntax checker is extended with language plugins and there just so happens to be one for PHP as well as HTML, although I'm not positive about CSS at the moment. Either way, as soon as you open a file or attempt to save one that has syntax errors, you can set up Syntastic to alert you in various ways:

* A statusline flag appears when syntax errors are detected
* |signs| are placed beside lines with syntax errors, where a different
  sign is used for errors and warnings.
* The :Errors command is provided to open a |location-list| for
  the syntax errors in the current buffer

Be sure to check out the helpdoc as there is a ton of useful info in there.

https://github.com/scrooloose/syntastic

like image 173
J.C. Yamokoski Avatar answered Oct 14 '22 08:10

J.C. Yamokoski


This Runtime syntax check for php may help you.

like image 26
Tassos Avatar answered Oct 14 '22 09:10

Tassos