Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Saturday, June 6, 2009

Inescapable Bafflegab in Vim

Assume that your vimrc has the following settings.

set encoding=utf-8
set termencoding=utf-8
set fileencodings=ucs-bom,euc-jp,cp932,iso-2022-jp

If you write the following phrase and save it,

カナサンスゴイ

and then you will see a bafflegab after re-open the file by :e. (You can resolve the bafflegab by :e ++enc=utf8.)

before

after

If there's other good words, for example 'あ', bafflegab will never appear.

Solution

Of course nobody can type :e ++enc=utf8 no matter when open the file. There are two easy solutions.

  • Add BOM. :setl bomb and :w.
  • Add other words if it's possible.

Note that modeline won't help the problem.

No comments:

Post a Comment

Followers