Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
created 2006 · complexity basic · author anand · version 5.7
It turns out that Internet Explorer executes "Notepad %1" when a user invokes View Source by right clicking etc.
So just drop a "Notepad.bat" on your desktop, to execute your choicest scripts, which in this case would be:
Above will start gvim with the source. The file notepad.bat has to be on your desktop.
Or, you can set the following registry key:
HKLM\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name (yes, this is the _key_ name)
Set the default value to the path and executable to vim, i.e. f:\pkg\vim\vim63\gvim.exe
For both the notepad.bat and registery suggestion, how would one ensure that -- when an instance of gvim (or vim) is already open -- that instance is used rather than a new gvim launched?
To Start all IE view sources files in same instance of gvim use following in Notepad.bat (or registry?)
gvim --servername IEFILES --remote-silent %1
help/docs on servername and remote-silent will provide further info.
OK, but how would one write the following logic in notepad.bat:
1) Let var_name = "IEFILES" 2.a) See if (one or more instances of) gvim is already running. 2.b) If so, figure out the name of any one instance of gvim; suppose it turns out to be "RUNNING_GVIM". 2.c) Set var_name = "RUNNING_GVIM" 3) Issue the command: gvim --servername var_name --remote-silent %1
I'd also like to suggest adding the command line parameter "+set syn=html" so that highlighting works even for poorly written HTML.
I've found the "ViewSourceWith" Firefox extension to be one of the greatest tools in my arsenal. https://addons.mozilla.org/firefox/394/
To sum all this up: (assuming default install path for vim7)
1. In Firefox, install https://addons.mozilla.org/firefox/394/
2. Configure ViewSourceWith to use:
Editor Path: C:\Program Files\Vim\vim70\gvim.exe Description: gvim Parameters: --servername "VIEW SOURCE" --remote-silent "+set syn=html" $f Shortcut: Shift+Ctrl+U
3. Create the file: C:\Program Files\Vim\vim70\ievim.bat with the following contents:
"C:\\Program Files\\Vim\\vim70\\gvim.exe" --servername "VIEW SOURCE" --remote-silent "+set syn=html" %1
4. Create the file: C:\Program Files\Vim\vim70\use_gvim_bat_file_for_IE_source_viewer.reg (filename is not important but the extension is) with the following content:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name] @="C:\\Program Files\\Vim\\vim70\\ievim.bat"
5. Open the reg file you just created and choose "yes" to putting the contents of the file into the registry.
Now both Firefox and IE will open page sources into the same gvim session WITH SYNTAX HIGHLIGHTING! The only caveat to this is that if IE is the first to launch the new gvim using the bat file, the cmd.exe window for the bat file stays open. You can simply close it yourself though. Once the gvim session named "VIEW SOURCE" is open, IE will not cause the cmd.exe window to stay open again.
I think this is awesome for someone like me who only uses Windows to see how the browsers treat my code. I still get that warm and vimmy feeling.
The .bat file method is stupid, and the registry key didn't work for me in IE8, but I found this, which does work: