Change File Encoding to utf-8 via vim in a script

前端 未结 4 1597
旧时难觅i
旧时难觅i 2020-12-12 13:54

i just got knocked down after our server has been updated from Debian 4 to 5. We switched to UTF-8 environment and now we have problems getting the text printed correctly on

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 14:14

    The accepted answer will keep the last file open in Vim. This problem can be easily resolved using the -c option of Vim,

    vim +"argdo set bomb | set fileencoding=utf-8 | w" -c ":q" file1.txt file2.txt
    

    If you need only process one file, the following will also work,

    vim -c ':set bomb' -c ':set fileencoding=utf-8' -c ':wq' file1.txt
    

提交回复
热议问题