nowox
nowox

Reputation: 29066

How to start GVim on Windows with vimfiles at custom location?

I am using Cygwin most of the time with my vimfiles on /usr/share/vim8/ and my runtimefiles at %HOME%\.vim.

I installed GVim for Windows and I would like to use the Vim files from Cygwin. When I start GVim it cannot find the runtimefiles. How can I configure it?

It does find my .vimrc tough.

Upvotes: 2

Views: 1046

Answers (1)

Anthony Geoghegan
Anthony Geoghegan

Reputation: 11983

If you want to share the configuration between Vim in Cygwin and native GVim, you could create a NTFS symlink from the Cygwin $HOME/vim directory to the Windows %HOMEPATH% directory. I use the same set of configuration files for Vim regardless of whether it’s running on a GNU/Linux system, Cygwin or native Windows. Here’s the Windows command that I used to create my NTFS symlink (with Windows 7, the mklink command must be run in a command window with elevated privileges).

mklink /D %HOMEPATH%\vimfiles C:\cygwin64\home\anthony\.vim

Also, instead of using _vimrc (MS Windows)or ~/.vimrc (Unix-like) for the primary vimrc, I use $HOME/.vim/vimrc. With the above symlink, this will automatically be found (and used) by GVim as $HOME/vimfiles/vimrc.

For configuration settings that only apply in a Windows environment, you can include a configuration block in your vimrc similar to the following:

if has("win32") || has("win64")
    set guifont=Consolas:h10:cANSI
    " Other Windows-specific configurations, e.g., key mappings
    source $VIM\_vimrc
endif

Upvotes: 2

Related Questions