Wikia

Vim Tips Wiki

Switching between different versions of Vim on Windows

Talk0
1,610pages on
this wiki
Revision as of 12:35, July 15, 2012 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 1670 Printable Monobook Previous Next

created October 31, 2010 · complexity basic · author Alexjak · version 7.0


Using the Windows installer to install Vim with default settings will put the executable in a directory with a name like C:\Program Files\vim\VimXX (where XX is a number such as 72 to indicate version 7.2). When the next version is installed, files will be placed in a new subdirectory, for example Vim73 for version 7.3. This tip describes how to handle the fact that you may have registered Vim as the editor to be used with various applications, and now the path to the executable needs to be changed in multiple locations.

Standard procedureEdit

The Vim Windows installer offers an option to create a batch file in a directory in the PATH so that batch file can be used to invoke Vim. Just use this batch file to register Vim everywhere. When a new version of Vim arrives, modify this file only (or the installer can do it).

Problems:

  1. An irritating black box (command prompt) is visible when Vim is started.
  2. In some circumstances, the name of the executable may be required, and a batch file is not sufficient.

Overwrite old versionEdit

Install the new version of Vim on top of the old one.

Problems:

  1. Cannot switch between versions, just upgrade.
  2. After a time, the Vim install directory becomes a mess, containing files from multiple versions.
  3. If Vim was initially installed in Vim72, it is confusing to use that directory to hold version 7.3.

Directory linkEdit

When installing Vim on an NTFS file system (pretty much all new computers), do the following:

  1. Go to the Vim directory (for example, C:\Program Files\vim).
  2. Create a junction (or, better, a symbolic link) named "runtime" to the directory with the executable (for example, C:\Program Files\vim\vim73). The name runtime is important! The linkd command can create and safely delete junctions, see Microsoft's How to create and manipulate NTFS junction points article
  3. Wherever you need to specify a path to gvim.exe, use the path that goes through "runtime".

When a new version of Vim arrives, do the following:

  1. Install it in the same main directory, but a different subdirectory (for example, when Vim 7.4 is available, it would be installed in C:\Program Files\vim\vim74).
  2. Go to the Vim directory (for example, C:\Program Files\vim).
  3. Delete the existing junction "runtime" (first close all running Vim instances). Warning: Do NOT simply delete the "runtime" directory from a file explorer or with a del command, this will also delete the contents of the "real" directory it links to. You must use the same tool you used to create the junction, to remove it.
  4. Create a new junction "runtime" to the directory with the new executable (for example, C:\Program Files\vim\vim74).

That way, all Vim settings throughout the system should pick up the new Vim version.

CommentsEdit

The easiest way I've found to handle a Vim version upgrade (and also, incidentally, to enable a quick setup on any new system), is to create a .bat file or a registry export file which can be used to create all your file associations. When you upgrade, simply change the path to Vim in this script/registry file and re-run/re-import it to override all the old associations with the new. --Fritzophrenic 04:17, July 8, 2011 (UTC)

Around Wikia's network

Random Wiki