On 14/08/10 10:41, coolesting wrote:
As the topic, i want to debug the php-script of how to do with the map in the
vim,
if the firefox not existing in the current window or process, open it and
send a request by the url of the preceding setting ,
or jump to the firefox to executing an action of the flash page
just like the following,
map<F5> XXX-command
so, the "XXX-commad" how to do ?
Well, you can take advantage of the fact that if Firefox is already
running, the URL will be opened in the existing instance; but you may
have to build a file: URL out of the current file's full path if it is
not a remote file opened via netrw. Also, if the filename contains
characters "not acceptable in a URL", you'll have to percent-escape
them. If you want to percent-escape something above U+007F, you'll have
to percent-escape each byte of the UTF-8 representation.
Whether the file will be opened in a new Firefox window, or in a new tab
in the current window, depends on a Firefox preference about opening
files sent from another application, you must set it in Firefox.
Caveat: the following is untested
function ToURL(file)
if a:file =~ '^\%(http\|https\|ftp\|file\|rcp\|scp\):'
let rv = a:file
else
let rv = 'file:///' . fnamemodify(a:file, ':p')
endif
let rv = substitute(rv, '%', '%25', 'g')
let rv = substitute(rv, ' ', '%20', 'g')
let rv = substitute(rv, '\', '%5C', 'g')
let rv = substitute(rv, ',', '%2C', 'g')
" ... etc.
return rv
endfunction
map <F5> :exe '!firefox -browser -url' ToURL(expand(%))
Best regards,
Tony.
--
Sweater, n.:
A garment worn by a child when its mother feels chilly.
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php