
WINDOWS


An ad-hoc compilation of tips specific to using Vim on the Microsoft
Windows platform, all taken from other sources

Compiler: Steve Hall  [ digitect@mindspring.com ]
Updated:  2003 May 14
URL:      http://cream.sourceforge.net/WINDOWS.txt

**********************************************************************
DISCLAIMER

THESE TIPS ARE FOR ADVANCED  USERS  ONLY!  THEY  MODIFY  YOUR  WINDOWS
REGISTRY, SOMETHING THAT EVEN MICROSOFT HAS TROUBLE  DOING  CORRECTLY.
WE CAN PROVIDE ABSOLUTELY NO GUARANTEE THAT THEY WILL WORK AT ALL, AND
MAY EVEN COMPLETELY DESTROY YOUR ENTIRE SYSTEM AND DATA, AND  POSSIBLY
A FEW OTHERS NEAR BY. YOU USE  THESE  COMPLETELY  AT  YOUR  OWN  RISK!
**********************************************************************
______________________________________________________________________
README! {{{1

Backup

You are advised to back up your registry before using any of the tools
in this file. Simply run "regedit" and use the File.Export item to
save a backup before proceeding. On Windows 95 (possibly 98-ME), you
can also copy the lines below into a file "regback.bat", drop it onto
your path (C:\WINDOWS works) and run it. 

----| regbak.bat |----------------------------------------------------
  @echo OFF
rem Saves copies of Windows system registry files.

rem change to Windows directory
   C:
   cd \WINDOWS

rem turn off hidden/read-only/system attribute
   attrib -h -r -s SYSTEM.DAT
   attrib -h -r -s USER.DAT

rem back up (up to 9 versions)
   if exist SYSTEM.DA8 copy SYSTEM.DA8 SYSTEM.DA9 /Y >nul
   if exist SYSTEM.DA7 copy SYSTEM.DA7 SYSTEM.DA8 /Y >nul
   if exist SYSTEM.DA6 copy SYSTEM.DA6 SYSTEM.DA7 /Y >nul
   if exist SYSTEM.DA5 copy SYSTEM.DA5 SYSTEM.DA6 /Y >nul
   if exist SYSTEM.DA4 copy SYSTEM.DA4 SYSTEM.DA5 /Y >nul
   if exist SYSTEM.DA3 copy SYSTEM.DA3 SYSTEM.DA4 /Y >nul
   if exist SYSTEM.DA2 copy SYSTEM.DA2 SYSTEM.DA3 /Y >nul
   if exist SYSTEM.DA1 copy SYSTEM.DA1 SYSTEM.DA2 /Y >nul
   copy SYSTEM.DAT SYSTEM.DA1 /Y >nul

   if exist USER.DA8 copy USER.DA8 USER.DA9 /Y >nul
   if exist USER.DA7 copy USER.DA7 USER.DA8 /Y >nul
   if exist USER.DA6 copy USER.DA6 USER.DA7 /Y >nul
   if exist USER.DA5 copy USER.DA5 USER.DA6 /Y >nul
   if exist USER.DA4 copy USER.DA4 USER.DA5 /Y >nul
   if exist USER.DA3 copy USER.DA3 USER.DA4 /Y >nul
   if exist USER.DA2 copy USER.DA2 USER.DA3 /Y >nul
   if exist USER.DA1 copy USER.DA1 USER.DA2 /Y >nul
   copy USER.DAT USER.DA1 /Y >nul

rem reinstate original attributes
   attrib +h +r +s SYSTEM.DAT
   attrib +h +r +s USER.DAT
---------------------------------------------------------------------

_____________________________________________________________________
Documentation {{{1

Sources:
o Vim help document "gui_w32". (Specifically sections
  "win32-popup-menu", "install-registry" and "send-to-menu".)
o "Vim", Section 5 "Configuring Internet Explorer v5", by Freddy
  Vulto. http://home.wanadoo.nl/fvu/Projects/Vim/Web/vim.htm.
o Various mails to vim@vim.org list from Colin Keith, Pritesh Mistry,
  and Dan Sharp on Feb 1-2, 2003. ()

Notes:
o Verify paths in all cases! We assume the path
    C:\Program Files\vim\vim61\gvim.exe
  but your installation will likely vary.
o Note that path backslashes must be doubled and that all paths must
  be double quoted to protect possible spaces in paths.
o You can define the character used for the shortcut by defining a
  name for the command and placing an ampersand ("&") before it in the
  name of the command. i.e "Edit with g&Vim".

______________________________________________________________________
Default Vim Registry Entries {{{1

These are the default registry actions taken by Vim's install.exe and
uninstall.exe.


----| vim-registry-install.reg |--------------------------------------
REGEDIT4

; Source: Vim help (:help install-registry)
; Tested: 2003-03-05

[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]
@="Vim Shell Extension"
[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]
; *** VERIFY PATH BELOW ***
@="C:\\Program Files\\vim\\vim61\\gvimext.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\gvim]
@="{51EEE242-AD87-11d3-9C1E-0090278BBD99}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]
"{51EEE242-AD87-11d3-9C1E-0090278BBD99}"="Vim Shell Extension"

[HKEY_LOCAL_MACHINE\SOFTWARE\Vim]
[HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]
; *** VERIFY PATH BELOW ***
"path"="C:\\Program Files\\vim\\vim61\\gvim.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Vim 6.1]
"DisplayName"="Vim 6.1 (self-installing)"
; *** VERIFY PATH BELOW ***
"UninstallString"="C:\\Program Files\\vim\\vim61\\uninstall-gui.exe"
----------------------------------------------------------------------

----| vim-registry-uninstall.reg |------------------------------------
REGEDIT4

; Tested:

[-HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]
[-HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]

[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\gvim]

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]

[-HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Vim]

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Vim 6.1]
----------------------------------------------------------------------

______________________________________________________________________
Context Sensitive "Edit with Vim..." Menu {{{1

Create a Vim entry in the right-click menu that is context sensitive,
that is it will present different options depending on the context.
These require the use of the gvimext.dll that is distributed with Vim.
Of course, you must edit the path to the correct location of the .dll.

NOTE: 
These are redundant with Vim's install.exe default behavior (above)!


----| context-sensitive-menu-install.reg |----------------------------
REGEDIT4

; Tested: 2003-03-18

[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]
@="Vim Shell Extension"
[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]
@="C:\\Program Files\\vim\\vim61\\gvimext.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\gvim]
@="{51EEE242-AD87-11d3-9C1E-0090278BBD99}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]
"{51EEE242-AD87-11d3-9C1E-0090278BBD99}"="Vim Shell Extension"

; Not sure if these are required, but won't hurt.
[HKEY_LOCAL_MACHINE\SOFTWARE\Vim]
[HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]
"path"="C:\\Program Files\\vim\\vim61\\gvim.exe"
----------------------------------------------------------------------

----| context-sensitive-menu-uninstall.reg |--------------------------
REGEDIT4

; Tested: 2003-03-18

[-HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]
[-HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]

[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\gvim ]

; Hmm... what if these involve more?
[-HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Vim]
----------------------------------------------------------------------

______________________________________________________________________
Context Insensitive "Edit with Vim..." Menu {{{1

If you always want "Edit with Vim" to appear in the context menu, you
can use these.


----| context-insensitive-menu-install.reg |--------------------------
REGEDIT4

; Source: Pritesh Mistry, 2/4/2003 1:16 AM mail to vim@vim.org list.
; Tested: 2003-03-18

[HKEY_CLASSES_ROOT\*\Shell\GVim]
@="Edit With g&Vim"

[HKEY_CLASSES_ROOT\*\Shell\GVim\Command]
@="\"C:\\Program Files\\vim\\vim61\\gvim.exe\" \"%1\""
----------------------------------------------------------------------

----| context-insensitive-menu-uninstall.reg |------------------------
REGEDIT4

; Tested: 2003-03-18

[-HKEY_CLASSES_ROOT\*\Shell\GVim\Command]
[-HKEY_CLASSES_ROOT\*\Shell\GVim]
----------------------------------------------------------------------

______________________________________________________________________
Open Unassociated MIME Types {{{1

Windows prompts the user to select a program to open unassociated file
types. To automatically open these with Vim without any prompting.


----| unassociated-MIME-WinNT-install.reg |---------------------------
REGEDIT4
; Source: VimOnline Tip #185, by Leif Wickland
;         http://vim.sourceforge.net/tip_view.php?tip_id=185
;
; o WinNT only!

; Tested:

[HKEY_CLASSES_ROOT\Unknown\shell\Open\Command]
@="\"C:\\Program Files\\vim\\vim61\\gvim.exe\" \"%1\""
----------------------------------------------------------------------

----| unassociated-MIME-WinNT-uninstall.reg |-------------------------
REGEDIT4

; o WinNT only!

; Tested:

[-HKEY_CLASSES_ROOT\Unknown\shell\Open\Command]
----------------------------------------------------------------------


----| unassociated-MIME-Win2000-install.reg |-------------------------
REGEDIT4
; Source: VimOnline Tip #185, comment by Klaus Horsten
;         http://vim.sourceforge.net/tip_view.php?tip_id=185
;
; o WARNING! This tip appears to tamper with the "Open With..." menu
;   and in some cases remove it. We can't recommend using it.
; o Win2000 only!

; Tested:
; o Win2K (David Menuhin)

[HKEY_CLASSES_ROOT\Unknown\shell\openas\command]
@="\"C:\\Program Files\\vim\\vim61\\gvim.exe\" \"%1\""
----------------------------------------------------------------------

----| unassociated-MIME-Win2000-uninstall.reg |.......................
REGEDIT4

; * Win2000 only!

; Tested:

[-HKEY_CLASSES_ROOT\Unknown\shell\openas\command]
----------------------------------------------------------------------

______________________________________________________________________
Send To {{{1

Simply copy a shortcut of gvim.exe into your profile's SendTo folder.
In WinXP, this is "C:\Documents and Settings\[username]\SendTo".
In Win95, this is "C:\Windows\SendTo"
In WinNT, this might be somewhere in between. ;)

(See also :help send-to-menu in the Vim on-line help.)

______________________________________________________________________
Internet Explorer, Edit With Vim {{{1

You can use Vim to edit local files browsed with Internet Explorer.
Just use the registry entries below and restart IE. Then use the
Alt+F,D keyboard accelerator for fast editing.


----| ie-editor-install.reg |-----------------------------------------
REGEDIT4

; Do NOT modify ".html" list, registry for ".htm" accomplishes both.
;
; Notes:
; o Windows (or gVim?) appear to ignore the quoted argument for the
;   file name and pass paths with spaces as separate items.

; Tested:
; o Win2K (David Menuhin)

[HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell\edit\command] 
@="\"C:\\Program Files\\Vim\\vim61\\gvim.exe\" \"%1\""
----------------------------------------------------------------------

----| ie-editor-uninstall.reg |---------------------------------------
REGEDIT4

; Tested:

[-HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim]
[-HKEY_CLASSES_ROOT\.html\OpenWithList\Vim]
----------------------------------------------------------------------

______________________________________________________________________
Internet Explorer, View Source {{{1

To change the default View.Source editor for Internet Explorer, you
can use the following method. (Note that the previous information for
changing Internet Explorer's "Edit with Vim" entry is more efficient
and doesn't require a VBS referer as this tip does. It also has a
slightly more reachable Alt+F,D accelerator key combination as opposed
to the View.Source Alt+V,C.)

Sources:

* VimOnline Tip #118, by Freddy Vulto:
    http://vim.sourceforge.net/tip_view.php?tip_id=118
* VimOnline Tip #190, by Hal Atherton, tested on WinXP and
  IE6: 
    http://vim.sourceforge.net/tip_view.php?tip_id=190
* VimOnline Tip #134, by Eric Lee, tested on WinXP and
    http://vim.sourceforge.net/tip_view.php?tip_id=134


----| ie-viewsource.reg |---------------------------------------------
REGEDIT4

; Tested:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor] 
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name] 
; Does not work for paths and files containing a space...
;@="C:\\Program Files\\vim\\vim61\\gvim.exe"
; ...so use this, which redirects IE to a Visual Basic Script handler
@="C:\\Program Files\\vim\\vim61\\ie-viewsource.vbs" 
----------------------------------------------------------------------

----| ie-viewsource.vbs |---------------------------------------------
' Source:   http://home.wanadoo.nl/fvu/Projects/Vim/Web/vim.htm
' Orig. Name:   gVim.vbs
' ....................................................................
' Function: Start gvim, combining multiple arguments to single file argument.
' OS Version:   Windows 2000, XP (*** Fails on Windows 95 ***)
' Changes:  
'   2001-12-05: Added argument '-c "set filetype=html"' for Vim v6.
'   2001-09-05: Quoted 'oWShell.Run' filename argument, allowing spaces.
'   2001-05-18: Created.
' Author:   Freddy Vulto <fvu@fvu.myweb.nl>

' Tested:

  ' 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
  ' -c "set filetype=html": Set filetype to 'HTML'
oWShell.Run _
  """C:\Program Files\vim\vim61\gvim.exe """ & _
  "-R """ & sFile & """ " & _
  "-c ""set syntax=html""" & _
  "-c ""set filetype=html"""

  ' Destroy script object
set oWShell = NOTHING
----------------------------------------------------------------------

----| ie-viewsource-uninstall.reg |-----------------------------------
REGEDIT4

; Tested:

[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name] 
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor]
----------------------------------------------------------------------

1}}}
 vim:foldmethod=marker
