Remove-Empty-Lines-in-NotepadBeing a programmer, from time to time you come across scripts that have been uploaded incorrectly via FTP. This can often cause a number of empty lines that need to be removed, and upon each subsequent change more empty lines are added.

This can be a programmer’s nightmare, so what can you do about it and what’s the easiest way to handle it? For reference, there are a number of easy ways, but my weapon of choice in this situation is the freely available Notepad++.

Simply open the application, paste the text with the empty lines and perform a Search and Replace (Ctrl+H). In the ‘Find what’ field, add \n\r and leave the ‘Replace with’ field blank. Click ‘Replace All’ and the rest is history. Should all lines not be removed, simply keep clicking the ‘Replace All’ button until you have a perfectly formed array of code.

Please note: Ensure that the ‘Extended Mode’ radio button is checked at the bottom in the ‘Search Mode’ box, otherwise this will not work.