Vim plug-in for PHP automatic syntax check

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.