Due to the large number of PHP statements recently, it is inevitable that you may accidentally write less semicolons or other syntax errors. The general check method is to return to the command line to run php-l, or you can upgrade it and run it directly in Vim :! Php-l %, or bind this as a shortcut key, for example, mapF5 :! Php-l % CR, each time you press F5, you can immediately perform a syntax check. But I still feel a little uncomfortable.
Due to the large number of PHP statements recently, it is inevitable that you may accidentally write less semicolons or other syntax errors. The general check method is to return to the command line to run php-l, or you can upgrade it and run it directly in Vim :! Php-l %, or bind this as a shortcut key, for example, map F5 :! Php-l % CR, each time you press F5, you can immediately perform a syntax check. But I still feel a little uncomfortable.
Due to the large number of PHP statements recently, it is inevitable that you may accidentally write less semicolons or other syntax errors. The general check method is to return to the command line to run php-l, or you can upgrade it and run it directly in Vim :! Php-l %, or bind this as a shortcut key, for example, map :! Php-l % You can immediately perform a syntax check whenever you press f5. However, I still feel a little uncomfortable, because many ides perform real-time checks, and syntax errors are prompted next to the code line. Although real-time check is not necessary, automatic check is much more convenient than manual check. For example, automatic check is performed when the PHP file is saved.
So I wrote this phpcheck. vim plug-in. The basic function isCheck the syntax when saving the PHP file. If there is a mistake or misunderstanding, no error will be prompted.This plug-in may not be visible most of the time, but the prompt is displayed when a syntax error occurs occasionally by mistake.
The error message is shown in:
The error message contains the error message and the error row number.
Plugin download
Http://www.vim.org/scripts/script.php? Script_id = 1, 4984
Plugin installation
Put the downloaded phpcheck. vim in your ~ /. Vim/plugin/or plug-in/In the Vim installation path /.
Plug-in configuration
In most cases, configuration is not required. If your phpbin directory is not in the system environment variable, you can specify the phpbin path as follows:
Let g: PHP_SYNTAX_CHECK_BIN = '/apps/php/bin/php'
Original article address: Vim plug-in for PHP automatic syntax check. Thank you for sharing it with the original author.