开发者

Vim and ASCII extended characters?

I would like to know how can I set VIM 7.0 to show and work with ASCII extended characters without problem开发者_如何转开发.


Vim (which is what vi resolves to on most systems) readily supports extended character sets. You might need to tell Vim which encoding to use, though.

This is controlled by two options:

:set encoding
:set fileencoding

If you have loaded a file that displays incorrectly, you may use :set encoding=<new encoding> to force the appropriate encoding. This changes the interpretation of the characters on the fly. If you want to save the file in another encoding preserving the current interpretation of characters, use set fileencoding=<new encoding> to let Vim save the file in that encoding.

I recommend that you set utf-8 as the default encoding in your .vimrc.


Once the the characters are "extended" it's not ASCII any more.

However: Just use vim. ":help unicode" for more details.


The other solutions here didn't work for me. Vim told me that encoding and fileencoding were not supported options. That turned out to be because I was building from source myself, and I did not include the multi-byte feature. My two Macs are similar, but one of them enabled it by default while the other did not.

If you're building Vim from source like I was, include --enable-multibyte in your arguments to ./configure. In my case, Vim defaulted to UTF-8 and supported extended characters after that.


I would suggest you to try the following:

  • set the terminal to utf-8 (how to do that depends on your terminal; in PuTTY it's in the Window/Translation menu)

  • set your locale to utf-8 (how to do that depends on your OS; on my Debian box it's set LC_ALL=en_GB.UTF-8 for the current session and sudo dpkg-reconfigure locales for permanent system-wide changes) -- you can check your current locale with locale.

That's how it works for me (using VIM 7.1.314 and no .vimrc).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜