Friday, December 12, 2014

Re: VIM PHP

On Thu, 11 Dec 2014 16:24:42 -0500, David Fishburn wrote:

> On Thu, Dec 11, 2014 at 12:10 PM, Joydeep Chakrabarty
> <chalao.adda@gmail.com
>> wrote:
>
>> ...
>
>
>
>> Thanks for your interesting tips. I forgot to mention I am working on
>> Linux Mint 64-bit laptop. So I just changed "iexplorer.exe" to firefox.
>> But when I used the tip - "nnoremap <silent> <C-F5> :if expand('%:p:h')
>> != ""<CR>:! firefox %:p<CR>:endif<CR><CR>", it sent "firefox
>> /home/username/public_html/current_directory/program1.php" and it
>> didn't work. As I said in my earlier post I am using Php. So I have to
>> sent "http://localhost/current_directory/program1.php" to firefox.
>> I could use ":!firefox http://localhost/current_directory/%". But in
>> that case I have to write current_directory every time.
>> I need a general way to get the path from after localhost(=
>> ~/public_html) to filename.php ( = %).
>>
>>
> You just have to use an extra substitution command (and probably an
> execute statement).
>
> I think this should work for you.
>
> nnoremap <silent> <C-F5> :if expand('%:p:h') != ""<CR>:exec ":! firefox
> "
> . substitute(expand('%:p'), '\/home\/username\/public_html', '
> http://localhost', '')<CR>:endif<CR>
>
> You can replace :exec with :echomsg and see what will happen.
>
> Dave
>
> --

Thanks David,
It finally worked. I used -

nmap <F2> :w<CR>:exec "!firefox " . substitute(expand('%:p'),"\/home\/
username\/public_html","http\:\/\/localhost","")<CR>

Thanks again.
BTW, is there any way I can run this in background? Everytime I press F2,
firefox opens and I cannot use vim until I close firefox. So I need to
call this in background and I can edit in vim. Next time I press F2,
another tab in firefox will be opened.


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment