Community
    • Login

    Why is a \n appended at the end of my .txt file

    Scheduled Pinned Locked Moved General Discussion
    7 Posts 4 Posters 211 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Robert LeducR
      Robert Leduc
      last edited by

      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)

      Terry RT PeterJonesP 2 Replies Last reply Reply Quote 0
      • Terry RT
        Terry R @Robert Leduc
        last edited by

        @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

        Robert LeducR 1 Reply Last reply Reply Quote 2
        • Robert LeducR
          Robert Leduc @Terry R
          last edited by

          @Terry-R

          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

          Terry RT 1 Reply Last reply Reply Quote 0
          • Terry RT
            Terry R @Robert Leduc
            last edited by

            @Robert-Leduc

            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

            1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Robert Leduc
              last edited by PeterJones

              @Robert-Leduc,

              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 windows CR LF?” or whether you mean “why is there a newline sequence appropriate to my settings (either \n for linux LF, or \r\n for windows CR 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 newline

              33ce9d4d-094c-42ba-9517-bd7daf73e9ed-image.png

              1abf9c63-1e57-43cb-a50a-0691ee69f4a4-image.png

              So, 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)

              Robert LeducR 1 Reply Last reply Reply Quote 5
              • Robert LeducR
                Robert Leduc @PeterJones
                last edited by Robert Leduc

                @PeterJones You got it right! Thanks
                It is the .editorconfig doing that.
                I’ll correct it.

                Alan KilbornA 1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn @Robert Leduc
                  last edited by

                  @Robert-Leduc

                  Suggestion: If you don’t know what a plugin is doing, perhaps uninstall it.

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors