I typed a lot of Chinese characters in Neovim into a LaTeX file (.tex), and when I opened the file the next day all the characters became unrecognizable (everything looked great before I shut down my machine the first day): enter image description here

The file still works well, when I compile the .tex file into pdf everything was fine. I do can open the file with gedit to get all the correct Chinese characters and than paste them back to Neovim but that would be tedious.

This seems to be an encoding problem, I hope to get some insightful ideas about how to fix this.

  • 1
    Welcome to Vi and Vim! Can you check :verbose set encoding?, and you might want to check locale in a terminal too.
    – D. Ben Knoble
    Commented Oct 17, 2020 at 14:23
  • :verbose set encoding givesencoding=utf-8 Last set from ~/.config/nvim/init.vim line 28, I set it explicitly in the config file before writing this file. Locale in terminal gives all the items en_US.UTF-8. I start to wonder whether this is a plugin problem (related to LaTeX) , as many other Chinese files stay fine up til now (mostly written in markdown). I use plugins vimtex, coc-texlab and coc-vimtex.
    – Ahacad
    Commented Oct 17, 2020 at 16:09
  • You could use our classic How to debug my vimrc post to narrow it down a bit. I really am not sure if the characters are supported by en-UTF8 locales (unless they are strictly UTF-8 and they were input/saved that way)
    – D. Ben Knoble
    Commented Oct 17, 2020 at 16:18
  • Mysteries solved, I set fileencodings=utf-8 (beware the s) and things look well now. A similar question is here. This configuration seems to set vim to read a file using a specific encoding scheme.
    – Ahacad
    Commented Oct 18, 2020 at 1:10

1 Answer 1


Vim has 4 configurations related to encoding: encoding, fileencoding, fileencodings, and termencoding. Encoding is what vim uses internally, fileencodings sets the turn in which vim tries to figure out the current file encoding scheme, and the first successful scheme will be set as fileencoding. Termencoding is what is used when printing to screen (using terminal).

In my case, I used set fileencodings=utf-8 to solve the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.