Cross platform vim script development

I’ve developed vim-project on my Mac and I wanted to be sure that it worked on Windows too. I bought a Windows 8 license some time ago for only 29,99 € to update my Acer from Windows Vista. I could try the plugin in my Acer, but I wanted to have something similar to a Vagrant setup. So I’ve created a VirtualBox for Windows 8, but I’ve encountered some obstacles.

Uninstall windows 8

You can have only one installation of Windows 8. So I followed the instructions to uninstall the Windows 8 license from my Acer from How-To Geek

It wasn’t enough. I had to call Microsoft to activate Window 8.

Windows 8 upgrade with an empty disk

If you install windows 8 on an empty partition, you cannot activate your Windows 8. I have found how to fix the problem in the Microsoft forum

Installation of Vim

I’ve installed this version of vim

Setup of vundle in Windows

I’ve followed the instructions from Vundle for Windows to setup Git and Curl.

Shared Folder with VirtualBox

This is the hard part. I wanted to be able to modify my plugin from MacVim and then restart Gvim to test it.

To achive this, you need to configure a VirtualBox shared folder. Then you need to setup a network unit in Windows. The problem is that the network unit must be visible by all users, because the symbolic links are created as Administrator while vim is started as normal user.

I’ve found the solution on stackoverflow:

For this hack you will need psexec SysinternalsSuite by Mark Russinovich:

  1. Open an elevated cmd.exe prompt (Run as administrator). Press the right command. Write cmd and then <C-S-CR> (ctrl-shit-enter).

  2. Elevate again to root using PSExec.exe: Navigate to the folder containing SysinternalsSuite and execute the following command psexec -i -s cmd.exe you are now inside of a prompt that is nt authority\system and you can prove this by typing whoami. The -i is needed because drive mappings need to interact with the user

  3. Create the persistent mapped drive as the SYSTEM account with the following command net use z: \\VBOXSVR\gvim /persistent:yes

Now you can create the links, but you have to do this hack everytime you restart Windows.

Creating symbolic links in NTFS

My Gvim setup is in /Users/amiorin/Code/gvim, gvim from now on. gvim/_vimrc is a link to ~/.vimrc. vimfiles is not a link, but a real directory, because I use Vundle. But gvim/vimfiles/bundle/vim-project is a link to ~/.vim/bundle/vim-project. gvim is Z: in Windows 8.

Using an elevated cmd.exe (<C-S-CR)

mklink _vimrc z:\_vimrc
mklink /D vimfiles z:\vimfiles
# Vundle uses .vim also on Windows.
mklink /D .vim vimfiles

Inside Gvim


Then I removed my plugin from vimfiles/bundle and I have created a link from ~/.vim/bundle/vim-project to be able to use the same code in MacVim and Gvim.

Powerline with Consolas font

Here you find a patched consolas for powerline

set guifont=Consolas\ for\ Powerline\ FixedD:h12

Conditional .vimrc

Some configurations are specific to one manchine. I’ve used the function hostname() in this way.

if hostname() ==# 'air.local'
  set guifont=Menlo\ for\ Powerline:h12
elseif hostname() ==# 'TOSHIBA'
  set guifont=Consolas\ for\ Powerline\ FixedD:h12

air.local is the Mac and TOSHIBA is the Windows 8.


With this setup I can write my plugins in MacVim and test them on Gvim and MacVim at the same time without any copy and paste of files or any commit and pull. I could use Gvim, but I use a lot of shortcuts starting with the left command in MacVim and the left command used by VirtualBox is a dead key inside the guest os.