"Count" number of matches
-
Please do tip me off as to post guidelines missed, since it’s my first time in the forum.
As the title says, “Count” button in the Search dialog is my concern. In the past I gave it a lot of use for document update work I do as a “quick look” tool. I like it better than “find all” which is too much information for me. Anyway I think it’s really useful. I hope others agree.
I searched and saw lots of posts on the button grouping issue, and the “find within selection” issue, but nothing about the “Count” button itself not working. It doesn’t work anymore for me, and does anyone know about this bug, or can anyone tell me what might have gone wrong in my configuration to do this?
Lenovo T460s
Win 10 pro
High contrast display -
The count-matches feature works. To prove this to yourself, create a new file with the contents
ababa
, and search fora
, then hit Count – it should match threea
characters.You mentioned “grouping” and “find within selection”: if you have a selection, then depending on which version of Notepad++ you are using, the count may only be counting what’s in the selection. I forget when it happened, but at least the most recent version (v7.9.1) properly groups the Count and Find All… buttons to indicate that they respond to “in selection” checkbox.
Other than that, I would assume there’s an error in your search term compared to what you’re searching against.
Unfortunately, our crystal balls aren’t powerful enough to see what is going wrong for you. If you provide details about what your text looks like (paste the text into your reply, highlight the text, then use the
</>
button, to get it to format as plain text – this prevents the forum from assuming your characters include markup, which will mangle the text if it contains a variety of markdown characters), and without more details about your exact search settings (alt+printscreen
on the Search dialog and paste the image in your reply), there’s a much better chance for us being able to help you. -
A recent change (not sure which version) to Count is that it counts “directionally” from the caret location, depending upon the state of the Backward direction checkbox.
Unless you have the Wrap around checkbox ticked; then it counts “globally” (the entire file). Globally is the old behavior whether or not Wrap around or Backward direction were ticked (and it may be what you are used to).
But this is fairly obvious if you actually read the output of the command. Example: If you are searching “downward” then it will say something like “Count: 3 matches from caret to end-of-file”, so even when Count fails to find matches, you at least know what it did and can begin to troubleshoot why no matches were found (if you think there should have been).
Of course, as Peter mentions, the In Selection checkbox can come into play as well, and it trumps all, overriding even the Wrap around and Backward direction checkbox settings.
-
I had a thought that it might be valuable to better state the precedence of options that I mentioned earlier. Let me give it a go, in the form of a pseudocode flowchart:
Count option rules:
if "In selection" is ticked Count will be occurrences within the selected text (of a single, non-column-block) selection else if "Wrap around" is ticked Count will be occurrences within the entire document else if "Backward direction" is ticked Count will be occurrences from the start of document to the (main) caret else Count will be occurrences from the (main) caret to the end of the document
The use of “(main)” is important if you have multiple carets active at once (i.e., multi-editing enabled).
You only have one “main” caret, which is the most-recent one you created.