David Fishburn wrote: > On Wed, Dec 10, 2014 at 2:47 PM, Joydeep Chakrabarty > <chalao.a...@gmail.com> wrote: > >> Hello, >> >> I am writing Php programs in Vim. My programs are in ~/public_html/test >> directory. When I run the program from web server, I write >> http://localhost/test/program1.php. >> I need a short cut so that it opens Firefox and replaces >> "~/public_html/current_directory/filename" to >> "http://localhost/current_directory/filename". >> >> > > Any of these will help you. > Just simply modify one of the ones that is closest to your needs. > > You would just have to add some extra substitutes for the path name that > launches. > > > if has("win32") > " Open the folder containing the currently open file. Double <CR> at > end " is so you don't have to hit return after command. Double quotes > are " not necessary in the 'explorer.exe %:p:h' section. > nnoremap <silent> <C-F5> :if expand("%:p:h") != ""<CR>:!start > explorer.exe %:p:h<CR>:endif<CR><CR> > > " This command will execute the file, for example, if this is an HTML > " file, it will run: > " start c:\absolute\filename.html > nnoremap <silent> <C-F6> :let old_reg=@"<cr>:let > @"=substitute(expand("%:p"), "/", "\\", "g")<cr>:silent!!cmd /cstart > <C-R><C-R>"<CR><CR>:let @"=old_reg<cr> > > " Visually select something and run it > " This can be anything you run from a command prompt like > " http://wwww.google.com > " notepad dave.txt > " dave.txt > " > " This one does not work if there are multiple parameters > " vmap <silent> <C-F5> :<C-U>let old_reg=@"<cr>gvy:silent!!start > rundll32 url.dll,FileProtocolHandler <C-R><C-R>"<CR><CR>:let > @"=old_reg<cr> > " This one works in all cases, but a cmd window flashes > vnoremap <silent> <C-F5> :<C-U>let old_reg=@"<cr>gvy:silent!!cmd > /cstart <C-R><C-R>"<CR><CR>:let @"=old_reg<cr> > > " Look up the dictionary/meaning of the word under the cursor > " Alternative: > " nmap \l :silent !start "c:\program files\internet > explorer\iexplore.exe" -nohome " > http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=<cword>"<CR>; > nnoremap <silent> <C-F2> :silent!!cmd /cstart > http://dictionary.reference.com/search?q=<cWORD><CR> > endif > > > > > > HTH, > David >
Hello David, 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 ( = %). Please help. Thanks again. -- -- 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.