How to run the php file with firefox in vimrc configuration? -
i have set php command line mode in vimrc configuration file.
nmap <f5> :!php %
it run current php file when press f5 key in php command line mode .
now want run current php file in firefox browser,how map f6 job?
nnoremap <f6>f :exe ':silent !firefox "http://127.0.0.1/". "%"'<cr>
it can't run when press f6 key.
think zach .
command changed nnoremap f :silent !firefox "http://127.0.0.1/%"
the file test.php
edited in vim ,my document root /var/www
, when press f6 , f ,the firefox opend.
http://127.0.0.1//var/www/test.php
not found
the requested url /var/www/test_equal.php not found on server. apache/2.2.22 (debian) server @ 127.0.0.1 port 80
the problem how fix "http://127.0.0.1/%" ,to change
http://127.0.0.1//var/www/test.php http://127.0.0.1/test.php
here current file /var/www/test.php (%).
why command can't run?
nnoremap <f6>f :silent !firefox -new-window "http://127.0.0.1/"{expand('%:t')}
edit: appears creating file in vim when aren't in directory begin (e.g. vim /path/to/newfile.php
instead of vim newfile.php
within directory) might change value of %
. in case grab tail using %:t
. try instead:
nnoremap <silent> <f6>f :!firefox 'http://127.0.0.1/%:t' &<cr>
tl;dr: on mac, should work:
nnoremap <f6>f :silent !/applications/firefox.app/contents/macos/firefox -new-window "http://127.0.0.1/<c-r>%" &<cr>
on linux or windows replace path firefox required.
if you're getting http://127.0.0.1//var/www/test.php
instead of http://127.0.0.1/test.php
need filename , not path. try using <c-r>%
instead (i'm referring path of firefox installation directly):
nnoremap <f6>f :silent !/applications/firefox.app/contents/macos/firefox -new-window "http://127.0.0.1/<c-r>%" &
if firefox
command setup, continue , use:
nnoremap <f6>f :silent !firefox "http://127.0.0.1/<c-r>%"
of course, assumes firefox
command correctly set up.
also, make sure file saved filename otherwise using %
won't work.
for people, using :silent
still brings hit enter contine prompt. if happens try adding &
@ end. e.g.:
nnoremap <f6>f :silent !/applications/firefox.app/contents/macos/firefox -new-window "http://127.0.0.1/<c-r>%" &
either way still ask press enter @ end. if isn't want add <cr>
or <enter>
@ end well. this:
nnoremap <f6>f :silent !/applications/firefox.app/contents/macos/firefox -new-window "http://127.0.0.1/<c-r>%" &<cr>
edit: there seem rather annoying problem in if use keybinding in vim firefox process running error saying 1 version of firefox can run @ 1 time. happens regardless of whether or not use -new-window
, -new-tab
or neither. seems an old bug reported in 2010 haven't been able find more recent. i'll see if can figure out solution other killing firefox if it's running (which yucky).
Comments
Post a Comment