GVim and Firefox together

Posted by fitheach on Tue 28 February 2012

I was curious about the structure of a web page and, did what I do dozens of times every week, right-clicked and selected View Page Source. However, in this case the web page was horribly complex and had all of the white space removed. I needed something more than the built-in Firefox/Iceweasel source viewer. After a little configuration I was able to bring GVim to the rescue. This is how I did it.

  • In the browser address bar enter:

about:config

  • Search for:

view_source.editor.external

  • and change the value to (by double clicking)

true

  • Now search for:

view_source.editor.path

  • and enter the path to your editor e.g.

/usr/bin/gvim

  • So, now when I right-click on a web page and select View Page Source I get an instance of GVim showing the code. However, I usually have GVim already running and it would be nice to have the page included as an additional tab in the existing instance. Adding arguments to the editor command inside about:config doesn't seem to work. Instead create a script with the included arguments

gvim gvim-moz.sh

  • and create the script

#!/bin/sh/usr/bin/gvim --remote-tab-silent $1

  • Lastly, go back to step three and this time enter the path to the script you just created. Now when selecting View Page Source it will be loaded in a new tab if GVim is already running.

I tested this process on Firefox/Iceweasel 9.x & 10.x, with GVim 7.3 running on Debian Wheezy.


Related posts: