How can I change a file's encoding with vim?

前端 未结 5 1650
庸人自扰
庸人自扰 2020-11-30 16:02

I\'m used to using vim to modify a file\'s line endings:

$ file file
file: ASCII text, with CRLF line terminators
$ vim file
:set ff=mac
:wq
$ file file
file         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 16:48

    Just like your steps, setting fileencoding should work. However, I'd like to add one "set bomb" to help editor consider the file as UTF8.

    $ vim file
    :set bomb
    :set fileencoding=utf-8
    :wq
    

提交回复
热议问题