windows 7 - Is there a way to prevent notepad from inserting new lines when using word wrap?

07
2014-07
  • Joan Venge

    I remember it wasn't doing this before but now when I am writing a few paragraphs and paste it into a forum post, I notice my lines were broken into new lines where I have to merge them manually.

    Is there a way to prevent this behaviour? I just want to see my text visible within the size of my notepad without horizontal scrollbars, but not have the text modified according to this.

  • Answers
  • Victor Stoddard

    Solution:

    Save the document and then re-open it in Notepad.

    Explanation:

    The carriage return (CR) and line feed (LF) are created with a new line in Windows text files, and both characters are needed to make text files compatible with old dot-matrix printers that had to be told to feed the paper. The CRLF has created all kinds of problems because sometimes these two invisible characters get unjoined.

    Since XP, Notepad sometimes adds an extra CR when the editor is in wordwrap mode and the document is saved; wherever the line wraps, a CR is put in. This creates a new line in the editor, which you can see when you change the client's size or edit existing lines. However, this problem is only visual, and the document is not saved with the extra CR.

    To solve the problem, simply save the document then re-open it in Notepad and it should look fine.

    One last note: this is not merely a painting problem but a problem with the text in the buffer, so copying the text to another editor does not solve the problem.


  • Related Question

    Notepad++ new line only inserting CR when opening empty file (0 byte text file created in Windows Explorer)
  • Davy8

    Background: I ran into a really odd issue where part of a php page just stopped parsing but only when it was uploaded to the server. Runs fine locally. The part where it cut off was after a commented line of code. Removed the comment it parsed up till the next comment.

    Turns out the issue was line endings. They were CR only without a LF, and the server being *nix doesn't recognize CR alone as a new line, thus it interpreted the comment as extending to the entire rest of the file.

    I tried creating a new file (after turning on "show all characters") inside Notepad++ and pressed enter. It showed CRLF.

    Next I created a new text file in Windows explorer (Win7 x64) then opened it in Notepad++. I pressed enter and it only inserted CR not LF.

    Now the actual question is why? As far as I know Windows should be based on CRLF not just CR. Also is there a way to have Notepad++ always use CRLF, or at least assume CRLF with a 0 byte file?


  • Related Answers
  • MBraedley

    I don't know why part of your file is in Windows format and part of it is in Mac format, but it should be as easy as selecting Edit->EOL Conversion->Windows Format, and the entire file should be converted to CRLF. Notepad++ uses the format that is used in the file that is opened. AFAIK, there is no way to force it. One option might be to show the line ending characters (View->Show Symbol->Show End of Line) so you know what you're dealing with when you open a file.

  • Davy8

    When opening a zero-length file, it uses the line-ending of the most recently opened file. That's why I was getting varied results.

  • Velociraptors

    You can set the default EOL format for new files in the "New Document/Default Directory" preferences tab. I believe the default is Windows, but if it's set to Mac format that may be why it used CR for the 0 byte file.