Question

I'm trying to set Sublime Text 2(ST2) as the external editor of Vimperator. (OS X 10.9.1, Firefox 27.0, Vimperator 3.8.1)

I used set editor="subl -w" and successfully launched Sublime Text 2 with the shortcut 'gF'.

However, I can only get "http" or "https" in ST2's window without any source codes. Is there any way to get the source code of current page viewing in ST2?

I noticed that in Vimperator's help docs:

View source with an external editor. Opens the source code of the current web site with the external editor specified by the 'editor' option. For now the external editor must be able to download and open files from a remote URL.

Is that because ST2 is not able to open remote files?

Any suggestions with be appreciated.

Was it helpful?

Solution

Indeed, SublimeText does not allow opening remote files, so the only way to view the file is to save it first. If somehow you may save the file first, you could open the local copy of it.

I don't use Vimperator, but I do have a bash alias for this:

curl -s http://mylink.com/x.html > /tmp/srcSublime && subl -a /tmp/srcSublime

This way sublime may be able to open the file. This has a major problem of being out of the browser session, so any link which requires authorization will most likely not work.

As I am not familiar with Vimperator, I don't know if it's able to save the source from the link and not only send the URL to an external program. If it's really posting the link for the external application, then it most probably won't work if the link is session-based. So if this is not a problem, you may try implementing my script (above) by making a global function in bash:

sudo vim /usr/bin/srcSublime and paste the following

#!/bin/bash
curl -s $1 > /tmp/srcSublime && subl -a /tmp/srcSublime

And your Vimperator editor command should simply be:

srcSublime

or when used outside of your vimperator as a shell command:

srcSublime http://url.to/source.html

Must have curl or try substituting curl with wget

OTHER TIPS

For whom are looking for an alternative solution. Append this configuration with your app in your ~/.mozilla/firefox/ramdom_profile/prefs.js

user_pref("view_source.editor.args", "-w");
user_pref("view_source.editor.external", true);
user_pref("view_source.editor.path", "/usr/bin/subl");

or edit the same variables in a new FF tab with about:config

BR

ps: unfortunately the gF, commands doesn't work but right clicking on the page->View page source or hit the context key at the keyboard and hit V, both solutions works as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top