7

I'm using cmder as my Win7 shell. I see the following behaviour:

Works fine (file in current directory):

vim test

Works fine (absolute path):

vim ~/test

Works fine (relative path with forward slash):

vim subdir/test

Does not work fine (relative path with backward slash):

vim subdir\test

The last example flashes the following in vim:

E303: Unable to open swap file for "subdir\test", recovery impossible.

Doing :set dir shows:

directory=~/vimswap

which exists and is permissioned correctly (after all, I don't get errors when opening absolute path files, only relative path ones).

I suspect this might have something to do with how cmder/vim represent relative paths - maybe a forward slash/backslash issue?

6
  • I don't know anything about cmder but what does set shellslash? show? If you set the opposite value in your vimrc file does it help?
    – B Layer
    Nov 13, 2017 at 4:21
  • How does cmder deal with path separators? The screencaps on the front page of the cmder web site show \ but looks like you are using /.
    – B Layer
    Nov 13, 2017 at 4:34
  • Interesting, set shellslash doesn't show anything. However, doing vim subdir\test works fine - it's the vim subdir/test command that fails. I think it's because windows paths use \ , but cmder seems to autocomplete with /. Nov 14, 2017 at 20:28
  • Sorry, got mixed up with the slashes, I've updated the question body. Nov 14, 2017 at 20:34
  • Not :set shellslash ... :set shellslash? ... you forgot the ? and turned shellslash on. Still, try putting set shellslash (this time without the question mark) in your vimrc and see if it matters. I suspect not, though. I think you just can't use the version you have with /.
    – B Layer
    Nov 15, 2017 at 1:18

2 Answers 2

0

I had this same problem and tracked it to the following.

I had set the following in vimrc

set backupdir=~/.vim/backup
set directory=~/.vim/tmp

But to make my work easier, I change the definition of HOME all the time.

When I did this, the ~ did not evaluate to a directory that had .vim/backup nor .vim/tmp in it. Hence, I got the error.

I changed the ~ to a fixed location and the problem went away.

This was under cygwin/Windows 11

0

The issue comes from Clink. A script has been submitted on their github, and Keith Milligan explains how to apply it:

Internally, cmder uses a utility called clink to enable bash-style command-line completion (and other things). You can enable forward-slash as a path separator, but adding some additional clink configuration to your cmder setup. If it does not exist, create cmder.lua in the config directory where you installed cmder. Add the following code:

local function force_fwd_slashes(text, first, last)
    clink.slash_translation(1)
    return false
end
clink.register_match_generator(force_fwd_slashes, -1)

Save the file and restart cmder. Paths will now be completed using forward slashes instead of backslashes.

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.