How to use UTF-8 in vim on Mac OS X?

4

I want to edit UTF-8 documents with vim (7.2 installed via MacPorts, big feautre set, iconv support enabled, multi-byte support enabled) on Mac OS X 10.4 within terminal.app.

Terminal.app is configured to use Monaco font (which has good Unicode coverage) and use UTF-8 as the character set encoding.

Keyboard map is set up correctly. I can enter some localized characters like „zażółć” and even quotes around that… (yeah, and an elypsis).

I've done my best to set up the environment:

LC_ALL=pl_PL.UTF-8
LC_CTYPE=pl_PL.UTF-8
LANG=pl_PL.UTF-8
export LC_ALL
export LC_CTYPE
export LANG

I have no encoding, fileencoding or termencoding set in .vimrc, so that it should default to what's set in the locale.

What else have I missed? I can't enter non-ASCII UTF-8 characters in vim. It is interpreted as single-byte garbage rather than wider UTF-8 characters.

Tadeusz A. Kadłubowski

Posted 2009-08-11T17:20:53.380

Reputation: 2 005

Answers

4

Check out this:

(Thanks to Peter Vohmann for this Q&A.) In Terminal.app go the the Terminal (main) menu and choose Window Settings. Select Emulation from the popup menu, un-check the item "Escape non-ASCII characters". Then select Display from the popup menu, set Character Set Encoding to Unicode (UTF-8), if desired. Click on "Use settings as Default."

(from MacVim Site)

As far as I remember, 10.4 Terminal.app has some troubles, when dealing with UTF-8; checking setting above would, probably, help. As an alternative solution, consider using MacVim or iTerm as terminal application.

Update: as Ben Stiglitz mentioned in comments, 10.4 Terminal is OK, but 10.4 bundled shells are not.

CoreSandello

Posted 2009-08-11T17:20:53.380

Reputation: 176

Thanks, this problem stumpted me for a while today, thinking why some characters didn't work no matter what encoding I used. – Johan – 2015-02-07T15:41:33.927

Links busted .... – slm – 2019-04-08T18:56:23.587

1Terminal 1.5 in 10.4 does fine with UTF-8 if you set your LANG properly. There are some issues with the shells, especially bash and tcsh, that were resolved in Leopard. – Ben Stiglitz – 2009-08-25T13:56:00.997

1Unselecting escape non-ASCII characters did the trick. I'll upgrade to snow leopard in a week or two anyway. Thanks – Tadeusz A. Kadłubowski – 2009-08-25T18:50:14.173

Did the trick for me! OS X 10.7.2, homebrew console Vim (to get clipboard support). – Wojtek Kruszewski – 2011-12-17T11:33:32.913

1

I don't know about Vim in the Terminal, but I have no troubles entering Korean characters in MacVim. This is with no extra setup, just as it came.

donut

Posted 2009-08-11T17:20:53.380

Reputation: 926