Ignoring empty lines counting
- 
@madara-san
I appreciate your (apparent?) desire to help people, but using generative AI is not the way to do this. StackOverflow has banned people from using ChatGPT, and for good reason.For example:
For example, in Notepad++, you can go to “View” > “Summary” to see a summary of the document, including the number of lines with and without blank lines.This is false, the
View->Summarytab does not include information on how many lines are empty.Use a regular expression (regex) to match and replace the blank lines. In most text editors, you can use the find and replace function and search for the regex pattern “^$” (which matches an empty line) and replace it with nothing.This is almost helpful, except that a quick attempt to actually do the thing you suggested reveals that while the find/replace form finds empty lines, the count feature does not count them. Also, the user doesn’t want to replace empty lines.
Honestly I don’t know why I waste my breath. I’d strongly urge the forum mods to ban this user if they don’t stop wasting people’s time with uncurated crud out of ChatGPT.
 - 
While I’m here, here’s a no-plugin way to get the answer (indirectly):
- Go to Find/replace form.
 Countthe occurrences of the following regex:^\h*\S+\h*$.
- This is the number of lines that don’t have only whitespace.
 - You can then subtract this number from the number of lines in the document, and that’s how many empty or whitespace-only lines you have.
 
TBH I think it’s pretty weird that the
Countfeature doesn’t count empty matches, and this could arguably be considered a bug. - 
@Mark-Olson said in Ignoring empty lines counting:
I think it’s pretty weird that the Count feature doesn’t count empty matches, and this could arguably be considered a bug.
Mark All also won’t do matches of zero-length (e.g. assert-only matches like
^$), but this perhaps is more understandable since there is no text to “mark”.Were you going to open a bug report issue about Count?
 - 
@Alan-Kilborn
Not sure if I want to open a bug report, because I can see why this could be considered intended behavior.I may open one later today.
 - 
@Alan-Kilborn
Actually, I came up with a good solution to the issue ofCountnot counting empty matches.
Show something like20 matches (including 10 empty matches)I’ll create an issue if you haven’t already, and then I’ll start on a PR.
 - 
Hello, @mark-olson, @alan-kilborn and All,
Regarding counting of lines, here are my solutions !
- First, insert this dummy text, below, in a new N++ tab
 
This is a small test to see if this test is OK That's the END- 
Open the Find dialog (
Ctrl + F) - 
Unchek all box options
 - 
Check the
Wrap aroundoption - 
Click on the
Countbutton or use theAlt + Tshortcut for all the examples below 
So, for one hand : ^\R count ALL lines with NO character ( True EMPTY lines ) => 5 lines + ^\h+$ count ALL lines with horizontal BLANK characters ONLY => 2 lines = ^\h*\R count ALL lines WITHOUT any NON-SPACE character => 7 lines + (?-s)\S.* count ALL lines with, at LEAST, 1 NON-SPACE character => 11 lines ( as well as (?-s).*\S ) = (?-s).*\R count ALL lines => 18 lines And for the other hand : ^\R count ALL lines with NO character ( True EMPTY lines ) => 5 lines + (?-s).* count ALL lines with, at LEAST, 1 character => 13 lines = (?-s).*\R count ALL lines => 18 lines
Notes :
- 
Just repeat the counting , using the
Markdialog, to better identify the class of the counted lines ! - 
Of course, you may use a normal selection of text and check the
in selectionoption to restrict the counting to that selection 
Best Regards,
guy038
 - 
I’ll create an issue if you haven’t already…
The issue that was opened:
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13608
 - 
Hi, @mark-olson, @alan-kilborn and All,
Did you notice this fact :
- The regex 
^$, indeed, does not count true empty lines ! 
but :
- The regex 
^\Rdoes count empty lines !! 
BR
guy038
 - The regex 
 - 
@guy038 said in Ignoring empty lines counting:
The regex ^$, indeed, does not count true empty lines !
but :
The regex ^\R does count empty lines !!
If the regex is purely an assertion, e.g.
^$or\b(to name but two), then its match won’t be counted by Count. - 
@Alan-Kilborn said in Ignoring empty lines counting:
@guy038 said in Ignoring empty lines counting:
The regex ^$, indeed, does not count true empty lines !
but :
The regex ^\R does count empty lines !!
If the regex is purely an assertion, e.g.
^$or\b(to name but two), then its match won’t be counted by Count.True (since a pure assertion is always an empty match), but empty matches aren’t counted regardless of how the regular expression is specified. In a file that has empty lines, but no lines containing only capital Ws,
^W*$counts zero matches.^\Rcounts all empty lines (except the last line, if it’s empty) because it isn’t an empty match: it matches line ending characters.^.*$and^.+$both count all lines that are not empty.