Remove Empty Lines Using Notepad++

Home/Remove Empty Lines Using Notepad++

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.

2017-05-19T15:48:04+00:00 July 22nd, 2014|Programming Tips|0 Comments

About the Author:

Warren Chandler is a freelance web programmer and web developer, based in Frinton on Sea, Essex. Warren specialises in web programming, web design, corporate identity, copy writing, SEO, logo and print media for home, work, and mobile platforms.

Leave A Comment