Page is a not externally linkable
- Code, Content, and Presentation
-- WYSIWYG and Text Code Editors
---- How can I automatically delete blank lines in an HTML document?


inbound - 5:54 pm on Mar 17, 2007 (gmt 0)


Using a better text editor would be a start. Textpad gets plenty of votes from experienced folk here, due to the regular expression support. This means you can search and replace very easily.

To get rid of extra blank lines in Textpad you would press F8 for 'search and replace' then pop \n\n into the find box, \n into the replace box and then make sure the tickbox for 'regular expression' is ticked, then press replace all. This searches for newlines immediately followed by another newline and replaces all occurences with a single newline, you may have to press this a few times until you get a message saying no occurences were found.

You may still see what appear to be blank lines as any spaces or tabs on a line will stop that line matching the above expression. The code for a tab is \t , so if (forsome strange reason) there is a tab on every blank line you would replace \n\t\n with \n

Learning how to use regular expressions can save you loads of time when working with text or data. Well worth looking into (even though it can be frustrating - keep backups until you are confident with it).

Good luck

Edit: spelling


Thread source:: http://www.webmasterworld.com/html_editors/3284810.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com