Objective: To make a gVim PHP plugin, execute the PHP scripting engine with the GVim make directive to check and output the currently open PHP script file.
Preparation environment: gvim,php
Steps:
1. Sudo mkdir/etc/vim/compiler
2. Sudo gvim/etc/vim/compiler/xampp-php.vim
3. Add the following to the Xampp-php.vim
1If exists ("Current_compiler")2 Finish3 endif4Let Current_compiler = "php"5 6If exists (": Compilerset")! = 2 "older Vim always used:setlocal7 command-nargs=* compilerset setlocal <args>8 endif9 Ten Let s:cpo_save = &CPO One Set Cpo-=c A - compilerset makeprg=php\-lq\% - compilerset errorformat=%e<b>%.% #Parse \ error</b>:\%m\ in\ <b>%f</b>\ on\ line\ <b> %l</b><br\/> the \%w<b>%.% #Notice </b>:\%m\ in\ <b>%f</b>\ on\ line\ <b>%l</b><br\/ , - \%e%.% #Parse \ error:\%m\ in\%f\ on\ line\%l, - \%w%.% #Notice: \%m\ in\%f\ on\ line\%l, - \%-g%.%# + - Let &CPO = S:cpo_save +Unlet S:cpo_save
4. Sudo gvim/etc/vim/vimrc.local
5. Insert the following at the end of the file:
1 autocmd filetype php compiler xampp-php " set compiler for PHP files 2 autocmd filetype php noremap <F5>:!/opt/lamp P/bin/php-f%<cr> "Set F5 key to run PHP file
6. Test the compiler settings correctly, create a new PHP file Gvim test.php
7. Type the following:
1 <?php 2 echo Hello World; 3 ?>
8. Enter the command: MAK, you should return the following results:
Input: CL is displayed as follows:
9. After correcting the compilation error, enter: Mak
Press <F5> should output the following:
Configuring the PHP compilation Environment for GVim