One thing at a time all the time!

Welcome to Rocteur
Friday, March 29 2024 @ 07:23 AM CET

How to save a file using different file encoding ?

:w ++enc=utf8 /path/to/new-file.txt

:help ++enc
:help encoding-values

-tim
Tim Chase

Similarly:

- to change the 'fileencoding' of the current file to UTF-8 and continue
editing:

:setlocal fenc=utf-8

- to save the current file under another name, with UTF-8 encoding, and
continue editing it under the new name:

:saveas ++enc=utf-8 newfile.txt

- to save the current file as UTF-8 and close its window (and exit Vim
if it is the last non-help window in the only tab)

:wq ++enc=utf-8

etc.


Best regards,
Tony.

FAQ Manager » Vim » How to save a file using different file encoding ?