homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
Forum Library, Charter, Moderator: open

WYSIWYG and Text Code Editors Forum

How can I automatically delete blank lines in an HTML document?
Using Notepad...

5+ Year Member

Msg#: 3284810 posted 5:12 pm on Mar 17, 2007 (gmt 0)

Is there an easy way to delete blank lines in a long HTML document using Notepad? When I look at the source code it has for some reason developed long sections of blank lines in between the lines of text. This hasn't affected the way the HTML page displays though. It just makes it very difficult to edit. Any help in working out the answer to this will be much appreciated!



WebmasterWorld Senior Member 10+ Year Member

Msg#: 3284810 posted 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


5+ Year Member

Msg#: 3284810 posted 7:55 am on Mar 19, 2007 (gmt 0)

Many thanks, Inbound. I tried what you suggested and it worked. A good tip!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / WYSIWYG and Text Code Editors
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved