At work I use neovim on Windows, and set the shell to bash using the bash executable that comes with Git for Windows (gitbash), which is in my PATH. The settings in the minimal init.vim pasted below mean that almost everything works as expected, but either reading or writing temporary files does not.

if has("win32")
 let &shell='bash.exe'
 let &shellcmdflag = '-c'
 let &shellredir = '>%s 2>&1'
 set shellquote= shellxescape=
 " set noshelltemp
 set shellxquote=
 let &shellpipe='2>&1| tee'

For example, executing :%!cat in nvim results in: E485: Cannot read file C:\Users\GREAF7~1.GLA\AppData\Local\Temp\nvimdVFZaL\1

If I immediately check in that directory, there is indeed no such file, so I assume writing the temp file is the issue.

If I uncomment the line " set noshelltemp then the command described will run successfully, but this isn't a solution because plugins such as Fugitive fail with temp-file related errors.

What am I doing (or not doing) wrong?


1 Answer 1


Adding let $TMP="/tmp" to init.vim, which should perhaps have been obvious, solved this with the exception of a couple of plugins which assume cmd.exe as the shell on Windows.

I had previously tried setting it to various other directories, but I was always making the mistake of specifying them with the Windows path format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.