Categories


Popular topics

 
Line 23: Line 23:
 
Replace With: ''""'' (without the quotes, i.e. nothing)
 
Replace With: ''""'' (without the quotes, i.e. nothing)
  
[[File:Deleteblanklines_new.png|right|alt=UltraEdit's Delete options]]
+
[[File:Deleteblanklines1.png|right|alt=UltraEdit's Replace with regular expression]]
  
 
You may need to click '''Replace all''' several times to ensure removal of all blank lines. Because of the way the the older regular expression syntax works, the replace might not replace all consecutive blank lines in your text file.
 
You may need to click '''Replace all''' several times to ensure removal of all blank lines. Because of the way the the older regular expression syntax works, the replace might not replace all consecutive blank lines in your text file.

Latest revision as of 21:49, 8 May 2026


If you notice that you have numerous blank lines in your file and you want to remove them, there is a faster process than manually deleting them.

UltraEdit v24.20 (and UEStudio v17.20) and later users can simply select Edit > Delete, and then select one of the following options:

  • Delete all empty lines. This selection deletes all lines in the file that contain no characters or whitespace. If text is selected, then the operation is restricted only to the selected text.
  • Delete all empty and whitespace-only lines. This selection deletes all lines in the file that contain no non-whitespace characters. This means that UltraEdit deletes lines containing literally nothing as well as lines containing only spaces and/or tabs. Again, if text is selected, then this operation is restricted only to the selected text.

If you have an older version of UltraEdit where Perl regular expressions are supported, you can use the following Perl regex to delete all blank lines in your text file. First make sure to enable Perl regular expressions by clicking the gear button in the Find dialog to show the advanced search options, or -- prior to UltraEdit v14.00 -- go to Advanced > Configuration > Search > Regular Expression Engine, and then enable Perl compatible Regular Expressions.

Find What: "^(?:[\t ]*(?:\r?\n|\r))+" (without the quotes)
Replace With: "" (without the quotes, i.e., nothing)

Note: Click Replace all once to replace all – even consecutive – blank lines in a text file.

If you have an older version of UltraEdit that doesn’t support Perl regex, you can delete all blank lines using a regular expression replace as follows. Note that first you’ll need to check the Regular expressions option in the Replace dialog.

Find What: "%[^t ]++[^r^n]+" (without the quotes)
Replace With: "" (without the quotes, i.e. nothing)

You may need to click Replace all several times to ensure removal of all blank lines. Because of the way the the older regular expression syntax works, the replace might not replace all consecutive blank lines in your text file.