2

Gvim 8.2 displays "Can't open file for writing" with a windows files that have a Unicode colon in the file name. Notepad, Wordpad, LibreOffice all work.

  • 3
    Welcome to Vi and Vim! There are a couple unicode colons, which code point is it exactly? – Jake Grossman Sep 28 at 3:52
  • OS Windows forbids colons in file names. Please, please, don't!! – Matt Sep 28 at 6:29
  • 1
    Are you sure this actually works in other editors? colons are used to denote alternate data streams on Windows. So this might actually have unwanted consequences. I would recommend not to use this. – Christian Brabandt Sep 28 at 7:28
  • 1
    I use Unicode colon FF1A – JerryD Sep 29 at 15:47
  • 2
    Jerry, add this info to the question itself (hit the small „edit“). Here in the comments it is difficult to find. – Ralf Sep 29 at 17:30
4

You mentioned in the comments, that the "unicode colon" is 0xFF1A. According to codetable.net this is a "Fullwidth Colon".

  • ":" (Fullwidth Colon)
  • ":" (normal colon)

I tested files with this character in its name on

  • Vim on Linux -> OK
  • Vim in Git Bash on Windows (MSYS2) -> OK
  • Vim on Windows -> NOT OK

I only have a rather old 8.1.2188 available on Windows 10. On loading the file the Fullwidth Colon was replaced by a normal colon. So in fact Vim is not editing the file given as parameter (or selected via file dialog or opened via drag and drop).

So this is not the problem you see, but there is something wrong.

The problem in this case is, that the encoding of Vim internally is "latin1", a single-byte character set. So the file name is converted to latin1 and this results in replacing the Fullwidth Colon with a normal colon.

I changed the internal character set by adding

set encoding=utf-8

as the first line of my vimrc.

Just try this. After you restarted Vim you can execute

:set encoding?

to validate that the encoding is really "utf-8". If not, something is resetting it -- maybe you have a superfluous set nocompatible.

With encoding set to utf-8 I can load and save the file containing the Fullwidth Colon in the name.

| improve this answer | |
  • Oh I see. I think, the default encoding setting for Windows should in my opinion always be UTF-8, but IIRC, Bram doesn't want to change this for backwards compatible reasons. – Christian Brabandt Sep 30 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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