I\'d like to be able to send the HTML file I\'m currently editing in vim
to my web browser, Chrome. I\'m running Linux.
This gets me very close:
From my .vimrc:
nnoremap <F12>f :exe ':silent !firefox %'<CR>
nnoremap <F12>c :exe ':silent !chromium-browser %'<CR>
nnoremap <F12>o :exe ':silent !opera %'<CR>
These three commands open the current file in the chosen browser without side effects. The use of <F12>
makes it GVim-only, though.
What about :!open % -a Google\ Chrome
?
I use the shell.vim
plugin to run commands in background on Windows. I don't know exactly what it does, but I believe it also works for that on Linux:
http://www.vim.org/scripts/script.php?script_id=3123
Shell.vim does allow for asynchronous external commands, but I don't know whether it allows you to keep focus with Vim terminal, avoid moving back manually.
Another plugin that allows asynchronous calls is below, although it relies on having Vim compiled with Python support and I haven't tested: https://github.com/MarcWeber/vim-addon-background-cmd
You can exec
chrome silent
ly:
nmap <silent> <leader>w :exec 'silent !google-chrome % &'
:exe[cute] {expr1} ..
Executes the string that results from the evaluation of {expr1} as an Ex command.
For windows 7 or 10 put this line into your .vimrc file:
nnoremap <silent> <F5> :!start file://C:/Users/<your username here>/AppData/Local/Google/Chrome/Application/chrome.exe %:p<CR>
or try:
nnoremap <silent> <F5> :!start file://C:/Program Files (x86)\Google\Chrome\Application\chrome.exe %:p<CR>
for more details see this link: Preview current HTML file
I wrote a small plugin with 7 commands to handle web searches.
After installing you could use:
:WSearchInit
to start a sites repository in the current folder:WSearchSaveTagAndSite google www.google.com/search?q={WSearch}
to save a site with corresponding tagand then search with:
:WSearch
will run your latest saved or searched site replacing {WSearch}
with the cursored word:WSearch Manual Search
will do the same as WSearch
but instead will replace {WSearch}
with Manual+Search.I hope it can help you or other people with the same problem.