Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 encoding in VIM

Tags:

vim

utf-8

I have no problem with UTF-8 chars in vim while editing, but when I do set fileencoding=utf-8 and then save and reload the file, vim displays nonascii chars incorrectly.

Why is that happening, and how to fix this?

like image 268
pbp Avatar asked Nov 29 '25 23:11

pbp


1 Answers

What is the value of your 'fileencodings' setting? This setting determines what encodings are tried by Vim to interpret the contents of a buffer that is being loaded. The first encoding that does not result in a conversion error is assumed to be the current file's encoding.

If utf8 is to be tested you should put it at the beginning of that setting.

Probably you have fileencodings set to latin1 for example. This encoding is always valid (there is no single byte combination that could be rejected).

If you don't want to change fileencodings you can reload the file with: :e! ++enc=utf8

like image 115
Benoit Avatar answered Dec 01 '25 18:12

Benoit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!