This worked for me:
ctrl + h
(Shortcut for replace)find what
box.
[\n\r]+$
or ^[\n\r]+
Replace with
box blankSearch Mode
, select Regex
Replace All
1) Ctrl + H
( Or Search Replace..
) to open Replace window.
2) Select 'Search Mode'
'Regular expression'
3) In 'Find What' type ^(\s*)(.*)(\s*)$
& in 'Replace With' type \2
^
- Matches start of line character(\s*)
- Matches empty space characters(.*)
- Matches any characters(\s*)
- Matches empty spaces characters$
- Matches end of line character\2
- Denotes the matching contend of the 2nd bracketRefer https://www.rexegg.com/regex-quickstart.html for more on regex.
this work for me:
SEARCH:^\r
REPLACE: (empty)
Sometimes \n\r etc not work, here to figure it out, what your actually regular expression should be.
Advantage of this trick: If you want to replace in multiple file at once, you must need this method. Above will not work...
/n/r
assumes a specific type of line break. To target any blank line you could also use:
^$
This says - any line that begins and then ends with nothing between. This is more of a catch-all. Replace with the same empty string.
^[ \t]*$\r?\n
into find what, leave replace empty. This will match all lines starting with white space and ending with carriage return (in this case a windows crlf)An easy alternative for removing white space from empty lines:
This will remove all trailing spaces, including trailing spaces in blank lines. Make sure, no trailing spaces are significant.
I did not see the combined one as answer, so search for ^\s+$ and replace by {nothing}
^\s+$ means
^ start of line
\s+ Matches minimum one whitespace character (spaces, tabs, line breaks)
$ until end of line
^\r\n
with nothing (select regular expression)Note: step 1 will remove your code intendation done via tabs and blank spaces
You can search for the following regex: ^(?:[\t ]*(?:\r?\n|\r))+
and replace it with empty field
A few of the above expressions and extended expressions did not work for me, but the regular expression "$\n$" did.
There is a plugin that adds a menu entitled TextFX
. This menu, which houses a dizzying array of quick text editing options, gives a person the ability to make quick coding changes. In this menu, you can find selections such as Drop Quotes, Delete Blank Lines as well as Unwrap and Rewrap Text
Do the following:
TextFX > TextFX Edit > Delete Blank Lines
TextFX > TextFX Edit > Delete Surplus Blank Lines
Ctrl+H.
find - \r\r replace with - \r.
Well I'm not sure about the regex or your situation..
How about CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines and viola all blank line gone.
A side note - if the line is blank i.e. does not contain spaces, this will work
In notepad++ press CTRL+H , in search mode click on the "Extended (\n, \r, \t ...)" radio button then type in the "Find what" box: \r\n (short for CR LF) and leave the "Replace with" box empty..
Finally hit replace all
CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines as suggested above works.
But if lines contains some space, then move the cursor to that line and do a CTRL + H. The "Find what:" sec will show the blank space and in the "Replace with" section, leave it blank. Now all the spaces are removed and now try CTRL+A, Select the TextFX menu -> TextFX Edit -> Delete Blank Lines
This obviously does not work if the blank lines contain tabs or blanks. Many web pages (e.g. http://www.guardian.co.uk/) contain these white lines, as a result of a faulty HTML editor.
Remove white space using regular expression as follows:
change pattern: [\t ]+$ into nothing.
where [\t ] matches either tab or space. '+' matches one or more occurrences, and '$' marks the end of line.
Then use notepad++/textFX to remove single or extra empty lines. Be sure that these blank lines are not significant in the given context.
Source: Stackoverflow.com