I am trying to start vimdiff from a cygwin shell but it is not working properly.
I start it with
gvimdiff.bat file1 file2
and the error messages I get is:
E810: Cannot read or write temp files
E97: Cannot create diffs
I tried setting different values for the TMP variable in _vimrc, something like
let $TMP="C:/tmp"
but this isn't doing any difference.
vimdiff works fine if it is started from a cmd shell.
I tried
:!diff -v
in gvim started from the cmd and from cygwin.
From cmd I get:
c:\windwos\system32\cmd.exe /c (diff -v)
diff - GNU diffutils version 2.7
From cygwin I get:
/bin/bash -c "diff -v"
The system cannot find the path specified.
sheell returned 1
Any idea how to make diff work on gvimdiff.bat started from cygwin bash shell?
Thanks.
Hi Christian,
the output for echo tempname() in gvim/windows is:
c:\htemp\tmp\VIBFED5.tmp
while the output for gvim/windows started from cygwin is:
c:/htemp/tmp/VIA693A.tmp
I use
if has("win32")
let $TMP = 'c:\\htemp\\tmp'
endif
to set the name of the variable but when started from cygwin it ends up with the separators in the oposite direction /.
Is it possible to set it in such a way that it would work?
Thanks!
Forward vs. backward slashes shouldn't matter, most Windows apps can handle both, cygwin apps can definitely handle forward slash, and a native Windows Vim can handle both.
Are you trying to access "c:/htemp/tmp" from a cygwin Vim, rather than a native Windows Vim? I don't use cygwin much (and never use Vim in cygwin) but apps I do use in cygwin don't understand C:/ paths, they use /cygdrive/c.
You said you were launching from cygwin with "gvimdiff.bat", is this actually true? Again, I don't use cygwin very often, but I know .bat files are scripts for the Windows cmd.exe shell, not for the cygwin shell, which uses bash or another unix shell. But maybe there is special handling built in to let it run cmd.exe scripts.
Sorry about that, I am just using the page in google groups to write the message, google groups is doing that by itself.
> You started a native-windows Vim from a cygwin shell. So Vim thinks the shell is whatever cygwin has it set to. However, once the native Vim is running outside of the cygwin environment, none of the cygwin paths are valid anymore. Vim doesn't know how to interpret /cygpath/c or /bin/bash or any of that. Native Windows Vim speaks native Windows file paths.
>
> You MIGHT be able to fix this by setting the 'shell' option, and possibly also 'shellquote', 'shellxquote', and optionally 'noshellslash'. But I'm not sure. Your best bet would be not to call native Windows applications from cygwin.
>
> You might also be able to set 'diffexpr' to a function which will select the correct diff, and also translate the paths passed in by cygwin.
>
I will try this an report later if it works.
thanks.
Now, that's funny. I've never had problems with it before. I'm using the Google Groups interface as well, but somehow this list uses a plaintext while other lists I'm on use "rich text" editors. I'm not sure if there's a hidden settings somewhere that I've forgotten about, or what.
Do other people see the HTML editor, or the plaintext editor, for this list on Google Groups?
It's doing it for me, too. I've reported it to Google from the little gear icon at the top of the page. We'll see if anything comes of it.
It does work if I change the value of shell, I don't even need to change the value of $TMP or shellxquote.
So now I have:
if has("win32")
"let $TMP = 'c:\\htemp\\tmp'
set shell=C:\Windows\System32\cmd.exe
"set shellxquote=(
endif
what I would like to have is
if has("win32") and shell.find('bash') >= 0
"let $TMP = 'c:\\htemp\\tmp'
set shell=C:\Windows\System32\cmd.exe
"set shellxquote=(
endif
my question now is how do this test, to check if the string bash is in shell?
Thank you.
You can access any option's value in a script by prepending '&' to the option name.
So in this case, you'd test for bash with something like:
" test for bash on Windows
if has('win32') && &shell =~ 'bash'
Or even better:
" test for pretty much any Unixy shell on Windows
if has('win32') && &shell =~ 'sh$'
or:
" test for Windows not using the default Windows shell
if has('win32') && &shell !~ 'cmd'
Thanks, I didn't know about these =~ and !~ operators. They seem to be similar to the ones in perl that I have trying to learn lately.
Best Regards,
Jorge