Why is a \n appended at the end of my .txt file
-
Why is a \n appended at the end of my .txt file
It was not doing that before.
Notepad++ v8.7.5 (64bit)
Notepad++ v8.7.5 (64-bit)
Build time : Dec 21 2024 - 05:13:03
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : -multiInst -nosession -openSession “f:\Users\xyz\Documents\xyz\NPP Sessions\xyz.ses”
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : OFF
Placeholders : OFF
DirectWrite : ON
Multi-instance Mode : multiInst
File Status Auto-Detection : cdEnabledOld (for all opened files/tabs) + cdAutoUpdate
Dark Mode : ON
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.5371
Current ANSI codepage : 1252
Plugins :
BracketsCheck (1.2.2)
Comment Wrap (1.0.0.7)
ComparePlus (1.2)
EnhanceAnyLexer (1.4)
HTMLTag (1.5.1)
LocationNavigate (0.4.8.1)
LuaScript (0.12)
MarkdownViewerPlusPlus (0.8.2)
Merge files in one (1.2)
mimeTools (3.1)
NavigateTo (2.6.4)
NppConverter (4.6)
NppEditorConfig (0.4)
NppExport (0.4)
NPPJSONViewer (2.1)
NppTextViz (0.4.2)
NppToolBucket (1.10.6622.41516)
NppXmlTreeviewPlugin (2)
PreviewHTML (1.3.3.2)
Python Indent (1.0.0.5)
PythonScript (2)
RegexTrainer (1.2)
SessionMgr (1.4.4)
XBrackets (1.3.1)
zoomdisabler_x64 (1.2)
_CustomizeToolbar (5.3) -
@Robert-Leduc said in Why is a \n appended at the end of my .txt file:
Why is a \n appended at the end of my .txt file
\n is used by a Linux (Unix) system. Has the file been altered by any Linux system in the interim?
Once you have it opened in Notepad++ you can fix this by using the Edit, EOL Conversion and select Windows (CR/LF). If that is dimmed, then select one of the others, then repeat and select the Windows one again. That will fix it.
Terry
-
I am on Windows, never Linux. So not touched there.
I can fix it, but as soon as I save it, it returns.
Notepad, does not do that!!
And np++ did not before -
You said appended, so ONLY the (second to) last line has this?
Can you think of any change you have made recently to either your file itself, or configuration changes in Notepad++.
How about opening a new file and type a single line and press enter to get the EOL type it thinks should be there. Post back what you saw.
Terry
-
Why is a \n appended at the end of my .txt file
It depends on whether you mean “why is it just
LF
when I am set to windowsCR LF
?” or whether you mean “why is there a newline sequence appropriate to my settings (either\n
for linuxLF
, or\r\n
for windowsCR LF
) at the end of my file, when I didn’t actually type an ENTER at the end of my file?” Because one is the question that @Terry-R answered, the second is my guess — oh, while answering this, I see you’ve continued the conversation, and I believe my guess is probably correct.NppEditorConfig (0.4)
You have the NppEditorConfig plugin. For the active file, does Plugins > Editor Config > Show EditorConfig settings for this file show
insert_final_newline = true
? if so, then your.editorconfig
file (either in the active directory or one of its parents) sets it so that the plugin automatically adds the newlineSo, assuming my guess is correct, it looks like you probably told the NppEditorConfig plugin to add newlines, then blamed it on Notepad++. (edit: or, alternatively, the repo that you have a checkout in which you are editing a file in had a .editorconfig that you didn’t know about, so your working copy started correctly honoring that repo’s settings once you installed the NppEditorConfig plugin – so maybe it was without your knowledge, but still because you have the plugin)
-
@PeterJones You got it right! Thanks
It is the .editorconfig doing that.
I’ll correct it. -
Suggestion: If you don’t know what a plugin is doing, perhaps uninstall it.