How to set "UTF-8 WITH BOM" as default Encoding even for old but changed textfiles?
-
As I found out I can change the default encoding for new text documents in
Preferences—New Document—Encoding
by enabling “UTF-8 with BOM”
Unfortunately this works only for new, really new documents.
When I load an existing old file (with UTF-8 only), then change something and save it, the old encoding remains.
How can I tell NP++ to apply the new default encoding to changed old files too?
If possible an additional option for this should be added to the next release.
Thank you
-
@Claudia-Svenson said:
How can I tell NP++ to apply the new default encoding to changed old files too?
I don’t believe this is possible.
If possible an additional option for this should be added to the next release.
This is IMO a dubious need.
For your use, perhaps a script that does an encoding conversion upon save would be beneficial?
-
@Claudia-Svenson said in How to set "UTF-8 WITH BOM" as default Encoding even for old but changed textfiles?:
When I load an existing old file (with UTF-8 only), then change something and save it, the old encoding remains.
How can I tell NP++ to apply the new default encoding to changed old files too?
I think you mean you want this to be automatic; but just in case you missed it, you can change the encoding of the file while you are editing it using Encoding | Convert to UTF-8-BOM. You just have to think to do it for every file you want to change.
-
The problem is that it is highly recommended to store
Powershell scripts with .ps1 extension
and (sometimes)
pure textfiles (ith .txt eextension
as UTF-8 with BOM.
In contrast it is urgently required to store
DOS batch scripts with .bat extension
and
Python scripts with .py extension
as UTF-8 WITHOUT BOM.
I cannot count how many times I hat the wrong encoding and experienced some weird execution problems.
Since I oftentimes use Notepad++ as initial script editor it would be the best place to auto-adjust Encoding here.Can I somehow let NP++ me warn when it detects a bad Encoding (depending on the current file extension) and suggest a switch? Even when I rename or edit an existing file?
This would be a great convenient enhancement feature.
-
@Claudia-Svenson said in How to set "UTF-8 WITH BOM" as default Encoding even for old but changed textfiles?:
This would be a great convenient enhancement feature.
Natively, there is no such feature (and it’s not likely to happen, IMO).
Using a plugin, it’s doable. For now, it requires using a not-yet-released version of the EditorConfig plugin, but they are supposedly eventually going to release a new version with all the features/fixes from the last 6 years.
EditorConfig plugin should be able to handle the
charsetattribute. But the version available in Plugins Admin is still 6 years old, and does not include that attribute. They merged the PR that implemented charset in 2023, but have not done a release since v0.4.0.0 in 2019. (In October 2025, they put in an Issue to encourage themselves to do a release, but there’s still apparently a showstopper preventing them from moving forward.)I just forked their repo, and did a build based on their most recent codebase; I call that “0.4.0.1”, so that there’s something to distinguish it from the official version. For a couple of months from 2026-Mar-30, GitHub should have some artifacts of my v0.4.0.1 build.
- Exit Notepad++
- Go to https://github.com/pryrt/npp-editorconfig-plugin/actions/runs/23767310769#artifacts and download the right artifact for your machine (most likely the one ending in
--x64). - Unzip, and copy the DLL to
c:\Program Files\Notepad++\Plugins\NppEditorConfig\NppEditorConfig.dll - create
.editorconfigfile at the top of your document structure (likec:\users\username\.editorconfig), populate it with:root = true [*.bat] charset = utf-8 [*.py] charset = utf-8 [*.txt] charset = utf-8-bom [*.ps1] charset = utf-8-bom - The next time you save a file with one of those extensions (as long as it’s in the same folder as the
.editorconfigfile, or a subdirectory of that folder), it will use the charset indicated when you save the file in Notepad++
(GitHub will remove those artifacts sometime in the next few months. If EditorConfig hasn’t done an official release since then, and the files are gone, feel free to ping me here, and I can trigger a new build to GitHub)