Why?
It’s all about the vim on windows' thing.
Gvim and vim-in-git
The official vim for windows (namely Gvim), compiled for win32 system, looks for user vim packages from windows style directory `$HOME/vimfiles`.
While the vim bundled with git for windows, which was compiled by mingw64, looks into a Unix style directory `$HOME/.vim` for the same thing.
The diverse of user packages will not cause any trouble, if you don’t have any vim related customization for yourself like me does. Things get changed until recently VIM upgraded to 8.0.
The new vim packages system
The new vim comes with its own package management system namely vim packages.
This package system makes it simple to install third-party vim plugins by just clone github plugin repo into the vimfiles directories.
- SOMENAME/pack/PACKAGENAME/start (for ftplugins)
- SOMENAME/pack/PACKAGENAME/opt (for colorscheme plugins)
How to merge the two vimfiles
- Solution 1: Make use of multiple repo management software such as `repo` or `gclient` to register and manage all the vim plugin repos on various directory as a whole.
- Solution 2: Manually maintain the repos in side a single place. First, combine home directory by set environment variable %HOME% with content of %USERPROFILE%. Then, make a Symbolic link `.vim` to `vimfiles` (which contains all the vim packages) directory.
How to create symbolic link?
If you are using Win7, as I do. Just download and install the awesome Link Shell Extension and follow the instructions in The Complete Guide to Creating Symbolic Links (aka Symlinks) on Windows
Or maybe using the `mklink` ****builtin**** (cmd.exe)
$ mklink
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link
$ mkdir vimfiles
$ mklink /j .vim vimfiles
Junction created for .vim <<===>> vimfiles
$ dir | findstr /i vim
12/12/2018 10:07 AM <JUNCTION> .vim [C:\Users\fktpp\vimfiles]
04/19/2016 01:05 PM 1,636 .viminfo
12/12/2018 10:07 AM <DIR> vimfiles
Lesson learns by failure attempts:
- Windows shortcut is not a symbolic link. It acts as a normal file if you try to access the shortcut inside git bash.
- `ln -s` command in git bash will not create symbolic link on windows, it merely create a copy of directory tree -_-
评论
发表评论