it_is_a_literature it_is_a_literature - 3 months ago 10
PHP Question

Why firefox can't open to parse my php in vim?

A simple php file was edited in /var/www/html/tmp/test.php.

<html>
<p>haha</p>
<?php
echo "test";
?>
</html>


To open it in firefox 127.0.0.1/tmp/test.php with firefox.

enter image description here

F12 was mapped to execute firefox to parse php file in the /etc/vim/vimrc.

nmap <F12>f :!firefox 'http://127.0.0.1/tmp/%'<CR>


Now to vim /var/www/html/tmp/test.php and press F12.

An ncredible reaction happened.

1.firefox was not called at all.

2.chrome was open to react,wrong result.

enter image description here

Answer

I can see at least a couple of things wrong.

One, the mapping you wrote is <F12>f which would be F12 and then the letter F.

Two, % expands the relative path to the file, in this case /var/www/html/tmp/test.php as you're executing vim from the home directory. The expansion you're looking for is actually %:t

:help expand

Comments