On Thu, Dec 11, 2014 at 4:24 PM, David Fishburn <dfishburn....@gmail.com> wrote:
> > > On Thu, Dec 11, 2014 at 12:10 PM, Joydeep Chakrabarty < > chalao.a...@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 > I found this blog post helpful. It explains how to open a URL (or a local file) from the command line on various systems: http://www.dwheeler.com/essays/open-files-urls.html This does not replace any of the vim-specific advice above, but it gives an alternative to specifying "firefox" as the command to open a browser. -- HTH Benji Fisher -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.