I have a simple tool for autorefreshing a page on save too, albeit you need to add a script tag to the html you are editing which adds a comet connection behind the scenes. Works across browsers so you can have IE, firefox, and chrome all running in different windows and see them all refresh every time you save a change.
And if you are on a mac, you can do something like this instead of the xdotool line:
silent !osascript ~/.vim/refresh.scpt
Where refresh.scpt looks like this:
tell application "Safari"
activate
set rURL to URL of current tab of front window
set URL of current tab of front window to rURL
end tell
Or like this (this form preserves the location on the page)
tell application "Safari"
activate
end tell
tell application "System Events"
tell process "Safari"
keystroke "r" using {command down}
end tell
end tell
You'd think so, but when I was doing some quick testing with just one window and multiple tabs it only refreshed the current tab. Doing some more tests now with multiple windows, it seems to only refresh the active tab of the back-most window in the stack.
I think that's rather counter-intuitive, but I doubt it'd be much of an issue in practice.
No vim hack required. However, this is my first hearing of MozRepl(out of the loop I know). I now have a bunch of ideas for interesting things that I can do with it, thanks!
Hey Antonin here. I'm the author of xrefresh from binaryage. Yes, my bad. I started this project in the times when I was pure windows user and has no awareness of X11 utility. xrefresh stands for "eXternal refresh" which sounded kinda cool.
Given the first letter of any technology and an English word, it's likely that there is a module / plugin / script / program with a name that combines the two.
For example, there are at least two "eproject" extensions for Emacs.
If the goal is not take your hands off the keyboard, why not save, then Alt-TAB once to get to Firefox, then Cntrl-R to refresh? This works with any editor (including my favorite, nvi).
I used to use the same keyboard sequence, but since I started using an editor with the ability to "refresh in running browsers", I can attest to value of the reduction in inane repetition. It's nothing life changing, but when you experience it it, the feeling is kind of like the one you have when you first encounter lights that come on automatically when you enter a room: "Hey, cool!"
It's just more keypresses mainly, but also you are unnecessarily changing focus to the browser. If you have your Vim session set to "Always on Top" or to one side, you never have to leave the editor to see your changes.
(On a side note, I wish I could use "Always on Top" in Windows. Anyone know if this is possible?)
Maybe this is well known, in that case disregard this submission. However, if your like me and never thought to do this and you do a lot of Sass or css editing in vim then this article is a huge help.
Note: make sure to include .sass, .erb in your .vimrc if your using Sass and Rails. For example
I've found that saving code, and refreshing the browser, then going back to code, then going back to the browser, is a terribly inefficient practice and horrible for flow. If you're finding yourself having to do this so often as to require a vim hack, you're doing something wrong.
Something like autotest for ruby projects, and cucumber / selenium etc should be making sure your code does what it is supposed to.
Horrible for code, maybe. For doing design with CSS(/Sass/etc) though it's essential.
I do :w, Alt-Tab, Ctrl-R constantly when I'm doing design. I'm constantly testing little changes. This looks like it could be quite a useful little hack.
Correct, I think for the most part it would be a bad way to test code. The only reason I included *.erb is for when I am editing the content/design of a page. Like changing a h2 to a h3 or something like that.
The poor man's version I use on Chrome is to add one of the plugins that will autorefresh every n seconds. It's far from ideal, but if I'm working on css it saves me a lot of time.
Another hack I've put together is to use applescript and a keyboard shortcut. Set it up as a universal shortcut and give focus to your code editor at the end of the script.
Why not generalize? Have a background process that watches the file, and whenever the modification time changes, refresh the browser. Then it works with any editor.
http://www.willwagner.com/autorefresh/