Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have Vim fully support UTF-8 on Windows

Tags:

vim

utf-8

I use vim and gVim on Windows, and vim in a virtual Linux box for programming. Often I need to change gettext catalog files. However, the support for Unicode characters seems to be incomplete in both Windows versions, perhaps because of the character set.

For example, umlauts (äöü) work just fine; but typographical quotes („“ or “ˮ) and some other characters like mdash and ellipse don't (they do in the Linux box). Vim complains about conversion errors and opens the files in read-only mode; when overriding this and storing anyway, those characters are broken.

Other Windows programs support those characters just fine, e.g. TortoiseSVN.

Note that this is not a “wrong encodingˮ matter, like latin-1 instead of utf-8, as this would affect the umlauts as well. I'm aware of the settings enc, fenc, fencs, and of :e ++enc=utf-8.

:version tells me: version 7.3, MS Windows 32 bit GUI version w/OLE support, including corrections 1-46; +multi_byte_ime/dyn.

Update: Updating to Vim 7.4 didn't solve the problem. +multi_byte_ime/dyn and, since the options are listed more readably now: +digraphs, -xfontset, -postscript (I don't know whether or not they are of interest).

Since I work on the same files with Linux Vim (still 7.3, including corrections 1-547) and, via Samba, the now updated Windows gVim, I tried the following: I opened a catalog file with the Linux version, which used to do the funny quote chars alright (:set enc? fenc?encoding=utf-8, fileencoding=utf-8) and saved it to be Latin-1 (:set fenc=latin-1 (File is marked changed), updated the markers, :w). I got a conversion error; however, some changes had been written.

When re-opening the file with the same Linux version, I got correct umlauts, encoding=utf-8 / fileencoding=latin-1, but incorrect quote chars.

like image 206
Tobias Avatar asked Jan 11 '23 03:01

Tobias


1 Answers

After reading the question How to view UTF-8 Characters in VIM or Gvim, I tried several guifont-settings (:set guifont? yielded nothing), and indeed some of them feature typographical quotes.

The following guifont settings worked for me on my Windows 8.1 system:

  • Lucida_Console
  • DejaVu_Sans_Mono
  • Courier_New
  • Consolas

For guifontwide I found

  • MS_Mincho

to work for chinese characters.

like image 153
Tobias Avatar answered Jan 22 '23 03:01

Tobias