Have been trying to debug an error of Cannot open file: C:/tmp/<blahblahblah>.tmp
when running fatih/vim-go under Windows. Can’t run :GoImports
etc, and by default it’s set to run gofmt
on save, so can’t even save files due to this issue (as all these commands run their formatting, write to a tempfile, and then copy the successful write over the top of your file).
Most of the time, this isn’t a problem as I tend to do most of my work on Linux-esque (either on a Macbook, or SSH’d to an Ubuntu Server). However, occasionally I do some programming at home and don’t want to pull out my laptop. If, like me, you use multiple operating systems and haven’t fully fine-tuned your dotfiles, you may have similar issues when switching between platforms, or even just getting this set up to run in windows in the first place.
I ended up determining the culprit to be the internal shell
configuration in vim. On Linux-like, I use zsh (set shell=/bin/zsh
). To fix it, we just need to have a conditional .vimrc
which sets a suitable shell
on windows.
set shell=cmd.exe
set shellcmdflag=/c