[email protected] ,
September 19, 2001 7:09
Great tip! Thanks....
Any ideas why this would work in IE 5.5 but not in IE 5.01 ? Strange....
Jake
[email protected] ,
September 19, 2001 7:19
Ignore that last note. Solved.
Was trying to do the same with TextPad. There is an option in there to "Allow multiple files on the command line". I needed to turn this off.
Sorry to polute this forum with non-Vim stuff ;)
Jake
[email protected] ,
September 19, 2001 7:45
The registry key given towards the end of this tip doesn't exist on my Win2K/IE6 system. A search for "notepad" in the registry turned up nothing relating to IE. Looks like M$ might have disabled this customization feature.
[email protected] ,
September 19, 2001 7:54
Please disregard my last comment. Serves me right for not reading the instructions carefully. This *does* work on Win2K/IE6.
[email protected] ,
September 20, 2001 20:01
How about adding a 'Install as default source editor of InternetExplore' option to the nsis win32-installer?
[email protected] ,
September 24, 2001 10:54
How to use this VBS script exactly?
[email protected] ,
September 24, 2001 10:55
Disregard my previous comment. Just saw the note about the registry change later.
[email protected] ,
September 24, 2001 18:12
I made a Win32 executable stub loader to do the same as the VBS:
http://www.csie.ntu.edu.tw/~b7506051/vim/VimThis0924.zip
(It'll query the registry for GVIM instead of hard-coded like the VBS above)
Just unzip and get the VimThis.exe, point your registry to its path.
[email protected] ,
September 25, 2001 13:02
Excellent, been trying to do this forever. Hated it when the file was "Too big for notepad" :)
thanx
alan
[email protected] ,
November 8, 2001 18:30
This tip kicks ass. As a minor modification I found it was nice to use the command:
oWShell.Run _
"""gvim.exe """ & _
"-R """ & sFile & """ " & _
"-c ""set syntax=html""" & _
"-c ""set filetype=html"""
By setting the filetype you can use advanced matching functionality (see vimscript #39 ) so you can match html tags.
[email protected] ,
November 11, 2001 9:06
This is terrific! NotePad is so-o-o clunky. However, I would like to be able to select a portion or all of the source and save it off as a file. I see in the gvim.vbs that there is a line that makes the file Read-only. My scripting skills are limited to learning PHP so far. If I remove the -R argument, will I be able to write the file to a directory or the desktop? And, while I'm thinking of it, can the script be adjusted to accomodate saving to a particular directory? I don't want to mess up the entire script. Thanks. Robert Roberts
[email protected] ,
November 11, 2001 9:25
Disregard the above except as an exercise, or just to know.
I've found a workaround in tip no. 71 ..."Transfer text between two gvim sessions using clipboard",
http://vim.sourceforge.net/tips/tip.php?tip_id=71
AND --- it works.
Thanks to all. Vim Rocks!
Robert Roberts
leifw @(at)@ bigfoot .(dot). com,
December 13, 2001 6:57
To summarize the improvements given above and to simplify the installation procedure, here's my rendition of this tip:
1. Copy the following into a filenamed gvim.vbs. A good place to put it is the root of your vim tree (e.g., c:\program files\vim\).
-------------Begin File: gvim.vbs-----------------
'--- gVim.vbs -----------------------------------------------------------------
'function: Start gvim, combining multiple arguments to single file argument.
'changes: 20010905: Quoted 'oWShell.Run' filename argument, allowing spaces.
' 20010518: Created.
'author: Freddy Vulto <[email protected] >
' Making variable declaration mandatory
option explicit
dim oWShell, sArg, sFile
' Create script object
set oWShell = CreateObject("wscript.shell")
' Loop through arguments
for each sArg in wscript.arguments
' Add argument to filename
sFile = sFile & sArg & " "
next
' Remove excess space
sFile = Trim(sFile)
' Run Vim with file argument. Additional arguments:
' -R: View file readonly
' -c "set syntax=html": Use HTML syntax-highlighting
' NOTE: Use "-c ""set ft=html""" to make it work for Vim v6.
oWShell.Run _
"""d:\program files\vim\vim60\gvim.exe """ & _
"-R """ & sFile & """ " & _
"-c ""set syntax=html""" & _
"-c ""set filetype=html"""
' Destroy script object
set oWShell = NOTHING
-------------End File: gvim.vbs-----------------
2. Change the path in gvim.vbs to point to your copy of gvim.
3. Save the following as a file named gvim.ie.vbs.reg (or something like that):
-------------Begin File: gvim.ie.vbs.reg-----------------
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name]
@="c:\\Program Files\\vim\\gvim.vbs"
-------------End File: gvim.ie.vbs.reg-----------------
4. Change the path in gvim.ie.vbs.reg to point to your copy of gvim.
5. Double click on the file gvim.ie.vbs.reg, or if you're already editing it in vim, execute the command line
:!start regedit "c:\program files\vim\gvim.ie.vbs.reg"
Of course, you can produce the file name by hitting control-r %.
[email protected] ,
January 4, 2002 19:29
Hmm... guess this doesn't work for Windows 95 (IE5.5). I get "Error: ActiveX component can't create object: 'wscript.shell'", "Source: Microsoft VBScript runtime error".
Any ideas?
john_mcdonnell.shift2.yahoo.company,
January 8, 2002 13:48
The person who reported a problem with Win95 should probably update their Windows Scripting Host. Try http://www.microsoft.com/msdownload/vbscript/scripting.asp
[email protected] ,
February 26, 2002 13:36
I added the registry entry for my Internet Explorer 6 and it works, although I only used Editorname=gvim.exe. So it looks like that IE 6 automatically puts quotes around filenames (and vim therefore can read \winnt\temporary internet files\... without any issues).
Or am I missing something?
Best regards, fcmensa!
[email protected] ,
March 27, 2002 15:51
Thank you very much. I now have a real editor to work with html files, not that excuse of an editor called Notepad! Keep up the good work.
[email protected] ,
May 14, 2002 13:41
umm... What this does for me is to open gvim.vbs instead of the actual source. Anyone know what I'm doing wrong?
Thanks.
[email protected] ,
May 14, 2002 13:48
Ignore that last one. I figured out what I was doing wrong (set the default for *.vbs to edit with Vim instead of execute).
[email protected] ,
September 12, 2002 11:17
I added this by just specifying gvim.exe and it works on filenames with spaces on IE6.
[email protected] ,
September 25, 2002 10:08
For people who hates VB scripts or does not want to have an extra .vbs file,
Look at: http://radio.weblogs.com/0100529/WinXp/#ie_editor
1. Open regedit, go to HKEY_LOCAL_MACHINE
2. Expand the key "Software"
3. Expand the key "Microsoft "
4. Expand the key "Internet Explorer"
5. Create key "View Source Editor" under "Internet Explorer"
6. Create key "Editor Name" under "View Source Editor"
7. Change the default value of key "Editor Name" to something named after the view you wish to use, in this example "vi.exe"
8. Close things up and expand HKEY_CLASSES_ROOT
9. Expand the key "applications"
10. Create a new subkey under "applications" with the same name from above. Ex "vi.exe"
11. Create a new subkey under the key created in the last step called shell.
12. Create a new subkey under shell called open.
13. Create a new subkey under edit called command.
14. Change the default value under the key command to the full path to your editor in quotes plus "%1" (with the quotes) Ex: "c:\vi\vi.exe" "%1"
Anonymous ,
February 1, 2003 10:14
An alternative (quick and dirty) solution is to rename notepad.exe (e.g. to _notepad.exe), and create a batch file called notepad.bat that runs vim instead. It works for me!
[email protected] ,
February 10, 2003 21:09
This site is amazing. Collectively the ideas in here, used in combination, made it possible for IE 6 to view the source again.
I tried everything, or at least I had thought. Nothing worked. After reading the second to last post on this board, and following its info, the ever so awful text editor, notepad, reappeared for the first time in months. So much for 'cleaning out the cache.'
Riddle me this; why did the creating of some registry strings cause my View Source option to work again? The keys I created seemed like legitimate key names, why weren't they in my registry to start with? With the new keys, View Source Editor, Editor Name and the value Notepad.exe, will the view source issue ever arise, or has it been forced into the backbone of IE6 for good?
Oh, btw, what is Vim? J/k!
Thanks guys, and girls
[email protected] ,
March 19, 2003 22:49
Fantastic - I got my notepad working again after 2 months without it! - just by making the keys..
Thanks!
shiloh at rvglug dot org,
May 6, 2003 10:36
Just to take this great tip one step farther. Here's how I added syntax highlighting to my source code.
" Open html files from Internet Explorer with certain commands
autocmd BufRead *\[[0-9]] runtime! syntax/html.vim
[email protected] ,
June 6, 2003 5:20
Here's how I added syntax colouring to the sourcecode.
Create a file scripts.vim in your user directory with the following code in. See :help filetype for more details. This also allows you to start creating an html file and type :filetype detect to get syntax highlighting as well. I'm sure the detection code can be improved, but it works for a first pass!
if did_filetype() " filetype already set..
finish " ..don't do these checks
endif
"Automatic detection of html files.
let s:line1 = getline(1)
let s:line2 = getline(2)
if s:line1 =~ '^<html*' || s:line2 =~ '^<html*'
set ft=html
endif
hashstat at eudoramail dot com,
July 14, 2003 9:37
You can avoid VBScript and EXEs by using a shortcut to Vim. This is especially useful on corporate computers where, for security reasons, scripting may be disabled.
1. Right-click gvim.exe in Windows Explorer and click 'Create Shortcut'.
2. Rename the shortcut to 'gvim_ie'. Running a directory listing (dir) at a command prompt reveals the real name of the shortcut as 'gvim_ie.lnk'.
3. Right-click the shortcut and click 'Properties'. Add the desired command-line parameters to the 'Target' field (i.e. '"C:\Program Files\vim\vim62\gvim.exe" -M -c "set syntax=html" -c "set ft=html"').
4. Point the 'Editor Name' registry key to the link.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name]
@="C:\\Program Files\\vim\\vim62\\gvim_ie.lnk"
This method was tested using Vim 6.2 on Win2K and Vim 6.1 on Win98.
[email protected] ,
August 7, 2003 17:07
Instead of using regedit to change "View Source Editor" directly, we can also use TweakUI for Windows XP (one of the "Powertoys for Windows XP").
Navigate to "Internet Explorer->View Source". Click "Change Program".
It changes the registry for you. (Exactly the same effect as using regedit.)
Regards.
rweaver at austin dot rr dot com,
September 12, 2003 11:27
Love it! I've set up IE to do this (via the "shortcut" method). Does anyone know how to do this for Mozilla and/or Netscape 7.x?
Regards.
[email protected] ,
September 26, 2003 9:14
I vote for the shortcut method! (simplest)
mrgrier at yahoo dot com,
January 6, 2004 1:34
The easiest way to get rid of this spaces problem is to rename your
Temporary Internet Files
folder to something without any spaces, i.e.
TempInetFiles
Windows will complain you're changing a system file folder name, but it works great, at least on my Win98se.
[email protected] ,
February 11, 2004 13:47
When I set this up, I had to create the keys for the View Source Editor, and its subkey "Editor Name".
In regedit:
1. Right Click on HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer and select "New" -> "Key".
2. Name the new key "View Source Editor"
3. Right click on the new key, select "New" -> "Key"
4. Name that new key "Editor Name"
5. In the right pane of regedit, double click "(Default)". This will open a pop-up to edit the value.
6. Enter the name of the shortcut, as in C:\Program Files\Vim\vim62\vim_ie.lnk
Right away I was able to View Source with VIM. If you have tried to View Source before making these changes, I suspect you would have to restart IE or even reboot.
[email protected] ,
February 23, 2004 11:22
I'm running Win98SE. I've made all the here to mentioned changes to my VB script and to _vimrc file and my syntax highlighting still does not work:
I added this to my _vimrc file.
" Only do this part when compiled with support for autocommands.
if has("autocmd")
autocmd BufRead *\[[0-9]] runtime! syntax/html.vim
endif
And I i'm using the VB script here:
option explicit
dim oWShell, sArg, sFile
' Create script object
set oWShell = CreateObject("wscript.shell")
' Loop through arguments
for each sArg in wscript.arguments
' Add argument to filename
sFile = sFile & sArg & " "
next
' Remove excess space
sFile = Trim(sFile)
' Run Vim with file argument. Additional arguments:
' -R: View file readonly
' -c "set syntax=html": Use HTML syntax-highlighting
' NOTE: Use "-c ""set ft=html""" to make it work for Vim v6.
oWShell.Run _
"""C:\Vim\Vim62\gvim.exe """ & _
"-R """ & sFile & """ " & _
"-c ""set syntax=html""" & _
"-c ""set filetype=html"""
' Destroy script object
set oWShell = NOTHING
This is all straight from this page. I was wondering if anyone else was having problems getting the syntax highlighting working under Win98SE.
[email protected] ,
February 25, 2004 11:38
Here's the latest update of 'gVim.vbs' (http://home.wanadoo.nl/fvu/Projects/Vim/Web/vim.htm ):
'--- gVim.vbs -------------------------------------------------------------------------------------
'function: Start gvim, combining multiple arguments to single file argument.
' This file is meant to be called from the Internet Explorer {View | Source} menu by
' adding the following keys to the registry:
'
' HKEY_LOCAL_MACHINE
' |- Software
' |- Microsoft
' |- Internet Explorer
' | |- View Source Editor
' | |- Editor Name (Default) = "C:\Program Files\Vim\gvim.vbs"
' |
' |- Windows
' |- CurrentVersion
' |- App Paths
' |- gvim.exe (Default) = "C:\Program Files\Vim\Vim62\gvim.exe"
'
'changes: 20040224 (FVu): Fixed 'InStr()' comparisons. Elaborate on variables. Properly
' initialized 'sPathFileSource'.
' 20040223 (FVu): - Location of 'gvim.exe' is now being retrieved from registry.
' - Filetype detection has been made more intelligent like this:
'
' V
' |
' ----+-----
' yes / Filename \ no
' +-<-+ has +->-+
' | \ extension? / |
' V ---------- |
' /* let Vim handle ----+-----
' filetype */ yes / file \ no
' +-----<-+ resides in +->-+
' | \ IE cache? / |
' | ---------- |
' +----------------+---------------+ +------+-------------+
' | Assume html/xhtml. | | Assume html. |
' | Rename '<file>' to <file>.htm | | Boldly specify Vim |
' | to let Vim's 'FTCheck_html()' | | startup arguments. |
' | find out if it's HTML or XHTML.| +------+-------------+
' +----------------+---------------+ |
' | V
' V
'
' Renaming to <file>.htm allows Vim to do its own HTML/XHTML detection.
' 20011205 (FVu): Added argument '-c "set filetype=html"' for Vim v6.
' 20010905 (FVu): Quoted 'oWShell.Run' filename argument, allowing spaces.
' 20010518 (FVu): Created.
'author: Freddy Vulto <fvu#wanadoo.nl>
' Oblige declaring variables
option explicit
' Windows Scripting Host object
dim oWShell
' Filesystem object
dim oFileSystem
' Single argument
dim sArg
' Path to source file as assembled from arguments
dim sPathFileArgs
' Path to source file as it will be passed to Vim
dim sPathFileSource
' Path to IE cache directory
dim sPathIeCache
' Path to Vim executable
dim sPathToVim
' Command line arguments to pass to Vim
dim sVimArgs
' Collect arguments into 'sPathFile' variable, separated by spaces
set oWShell = CreateObject("wscript.shell")
for each sArg in wscript.arguments
sPathFileArgs = sPathFileArgs & sArg & " "
next
sPathFileArgs = Trim(sPathFileArgs)
sPathFileSource = sPathFileArgs
' Is extension ext missing from file specification (dir\dir\file.ext)?
if (InStrRev(sPathFileArgs, ".") < (InStrRev(sPathFileArgs, "\"))) then
' Yes, filename is missing an extension;
' Does file reside in IE cache?
sPathIeCache = oWShell.RegRead( _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Cache")
if (InStr(sPathFileArgs, sPathIeCache) = 1) then
' Yes, file resides in IE cache;
' Rename '<file>' to '<file>.htm' so Vim can detect if its HTML or XHTML (see function
' 'FTCheck_html()' in 'filetype.vim')
set oFileSystem = CreateObject("Scripting.FileSystemObject")
sPathFileSource = sPathFileArgs & ".htm"
if (oFileSystem.FileExists(sPathFileSource)) then
oFileSystem.DeleteFile(sPathFileSource)
end if
oFileSystem.MoveFile sPathFileArgs, sPathFileSource
set oFileSystem = NOTHING
else
' No, file doesn't reside in IE cache;
' Better not rename file: assume file is HTML
sVimArgs = sVimArgs & " -c ""set syntax=html"" -c ""set filetype=html"""
end if
end if
' Run Vim with file argument. Additional arguments:
' -R: View file readonly
sPathToVim = oWShell.RegRead( _
"HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\gvim.exe\")
oWShell.Run sPathToVim & " -R """ & sPathFileSource & """" & sVimArgs
' Destroy script object
set oWShell = NOTHING
[email protected] ,
May 11, 2004 3:28
There seems to be an additional problem if one wants to use e.g. the --remote-silent option so that the file opens in an existing gvim session. I have the impression that the [-R -c "set ft=html" --remote-files] sequnce does not seem to work: the filetype remains unset, and the file is noreadonly. I adapted the script so that it first runs gvim --remote-silent to pass the file to the current gvim session, and that I use gvim --remote-send to switch to readonly and an additional gvim --remote-send to set the filetype. (Didn't work if both commands were sent together). Works like a breeze. Here's the script as I use it now:
'--- gVim.vbs -----------------------------------------------------------------
'function: Start gvim, combining multiple arguments to single file argument.
'changes: 20010905: Quoted 'oWShell.Run' filename argument, allowing spaces.
' 20010518: Created.
'author: Freddy Vulto <[email protected] >
'updated to work with remote vim session
' Making variable declaration mandatory
option explicit
dim oWShell, sArg, sFile
' Create script object
set oWShell = CreateObject("wscript.shell")
' Loop through arguments
for each sArg in wscript.arguments
' Add argument to filename
sFile = sFile & sArg & " "
next
' Remove excess space
sFile = Trim(sFile)
' Run Vim with file argument. Additional arguments:
' -R: View file readonly
' -c "set syntax=html": Use HTML syntax-highlighting
' NOTE: Use "-c ""set ft=html""" to make it work for Vim v6.
oWShell.Run _
"""gvim.exe """ & _
"--remote-silent " & _
"""" & sFile & """"
oWShell.Run _
"""gvim.exe """ & _
"--remote-send " & _
""":se ro<CR>"""
' I have no need to set the syntax separately
' This could be uncommented if need be
'oWShell.Run _
'"""gvim.exe """ & _
'"--remote-send " & _
'""":se syntax=html<CR>"""
oWShell.Run _
"""gvim.exe """ & _
"--remote-send " & _
""":se ft=html<CR>"""
' Destroy script object
set oWShell = NOTHING
@conley.org [doug],
May 18, 2004 18:35
Folks... The space before the last quote is critical... Otherwise, the arguments get jumbled like so:
-c "set syntax=html"-c "set etc..."
^^
+---> NOT good! That is why so many people are having problems with highlighting not working.
e.g.:
"-R """ & sFile & """ " & _
"-c ""set syntax=html"" " & _
"-c ""set ft=html"" "
@conley.org [doug],
May 18, 2004 18:40
again with fixed width font. ;-)
-=-=-=-=-=-=-=-
Folks... The space before the last quote is critical... Otherwise, the arguments get jumbled like so:
-c "set syntax=html"-c "set etc..."
^^
+---> NOT good!