跳至主要内容

Junction as symbolic link on windows 7+

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

  1. 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.
  2. 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:

  1. Windows shortcut is not a symbolic link. It acts as a normal file if you try to access the shortcut inside git bash.
  2. `ln -s` command in git bash will not create symbolic link on windows, it merely create a copy of directory tree -_-

 

评论

此博客中的热门博文

XEmacs 21.5 beta 35 "kohlrabi" has been released.

If you are an old XEmacs user, you may feel happy to see this from https://www.xemacs.org/.    After ten years, XEmacs released a new version 21.5. So there's still many people cares about XEmacs. The XEmacs' source repo have been moved from altassian Bitbucket to https://heptapod.net/. As Bitbucket have been dropped Mercurial support many years ago.

Fido-mode

Today, I've just discovered the Fido mode, a modified `icomplete` minor mode. `icomplete` used to be one of my favorite mode days back to my XEmacs days. Pros: It is way fast. It is much more smart in terms of find the complete candidate that you want mostly.  Cons: It does not integrate well enough with tramp yet.    `fido-mode` is a core package of Emacs 27+, and there's a vertical version available after Emacs 28+ named `fido-vertical-mode`. UPDATE: I am back with ido now