Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Make chrome refresh anytime I :write

I want a solution that does what's described in the vim wiki here, but that works on Chrome.

That is, I'm trying to avoid this:

  • Edit your HTML/CSS file.
  • Hit save in Vim.
  • CMD/CNTRL/ALT + TAB over to Firefox.
  • Press Ctrl-R in Firefox to refresh.
  • CMD/CNTRL/ALT + TAB back to Vim.
  • Do it again and again, wincing a little bit each time.

The vim wiki solution is for firefox, and other scripts and solutions I've found on the web are Mac only. But I'm on windows, and will often have vim open on the left half of the screen (editing html) and chrome open on the right half of the screen (displaying the file I'm editing).

A really "dumb" solution would work fine for me. That is, there wouldn't even need to be communication of the filename between vim and the browser. If I could just turn on a mode in vim, call it "auto-refresh", and now anytime I do a :w the currently active tab in chrome refreshes itself, without taking focus off the vim window. That would be perfect. Is it possible?

like image 849
Jonah Avatar asked Oct 04 '12 18:10

Jonah


2 Answers

I don't know how to reload a give chrome page from shell, however, I agree with Chiel92 that if you need to see your changes when file changes, you can do that from browser.

See LiveReload, works with Windows & Mac (not for me then) and supports Safari & Chrome.

LiveReload will check your main page as well all css and javscript that it depends from, if any of those changes, it will reload it.

They seems to have launched a second version, however official site of version 2 it's offline and doesn't seem version 2 it's on github either. (Version 1 it's it's on github)

like image 163
Valor Avatar answered Oct 10 '22 16:10

Valor


a solution that might work for you is in your html coding include the line in the head tag

    <meta http-equiv="refresh" content="30" />

this will reload the page every 30 seconds directly taking from w3schools.com now when you want to deploy it just remove that line

like image 1
5hammer Avatar answered Oct 10 '22 16:10

5hammer