How can I remove the BOM from a UTF-8 file? [duplicate]

Using VIM

  1. Open file in VIM:

     vi text.xml
    
  2. Remove BOM encoding:

     :set nobomb
    
  3. Save and quit:

     :wq
    

For a non-interactive solution, try the following command line:

vi -c ":set nobomb" -c ":wq" text.xml

That should remove the BOM, save the file and quit, all from the command line.

Leave a Comment