When using text editors such as Notepad++ to develop code, you may run into certain lines of code that are too long to fit in your text editor window. Having to scroll sideways to see all of the code on the line can make it harder to debug it and follow exactly what the code is doing.
Word wrap is a feature in many text editors such as Notepad++ that formats long lines of text by wrapping extra text onto multiple lines. Word wrapped lines are purely a visual effect and don’t actually change the number of lines in the code. To add a new line to code, a specific “newline” character has to be used, therefore, as Word wrap doesn’t add newline characters, a compiler doesn’t count the text as a new line. The wrapping effect is entirely dynamic and adjusts based on the width of the window.
Tip: The “newline” character is a whitespace character, similar to spaces and tabs. It can often also be referred to as a “carriage return”.
There are scenarios where Word wrap can potentially be more annoying than not having it. For example, if you’ve got an extremely large line of text, such as a base64 encoded image, a single line could stretch over more lines than fit on a full-screen window. In general, however, Word wrap can be a significant help as being able to see a whole line of code makes it a lot easier to follow exactly what that code does.
How to enable Word wrap
To enable Word wrap in Notepad++ you need to click on “View” in the top bar, then click on “Word wrap”.
Alternatively, you can click the thirteenth button from the right under the top bar. When you hover your mouse over the button it will say “Word wrap”.