Is it possible to automatically set UTF16 file encoding when opening a file of that type?

前端 未结 3 1275
南笙
南笙 2020-12-24 12:30

I edit all kinds of files with Vim (as I\'m sure most Vim users do). One bug bear I have is what Vim does when I come across a file with an odd encoding. Most editors (the

3条回答
  •  太阳男子
    2020-12-24 13:19

    Add this code to your .vimrc:

    if has("multi_byte")
      if &termencoding == ""
        let &termencoding = &encoding
      endif
      set encoding=utf-8
      setglobal fileencoding=utf-8
      "setglobal bomb
      set fileencodings=ucs-bom,utf-8,latin1
    endif
    

提交回复
热议问题