Show count of occurrences when smart highlighting in Notepad++
Asked Answered
U

3

32

Is it possible to show the number of occurrences of words which are smart highlighted? I mean when you double click on a word.

In Matlab e.g. smart highlighting is activated by having the cursor touching a word and in the tool bar it instantly says for instance 4 usages of "weight" found.

Doing a search for the word/phrase will give you the same information, but how about having the count directly be shown somewhere?

BTW: Can smart highlighting be activated in a different manner than double clicking?

Unpaid answered 6/1, 2015 at 7:16 Comment(0)
C
49

You can get counts of words or matches in other ways.

The normal Find window has a Count button. If you press it, it will display the total number of items found in the status bar of the find window.

Also the Mark tab of the Find window shows the number of items found when Mark all is pressed. In addition, the items found by this kind of search are highlighted permanently.

Chirpy answered 6/1, 2015 at 10:21 Comment(2)
No, this is not what @Unpaid asked for. Find does not instantly tell you the number of occurances, only after a few click. I would use this feature to check if some variable declarations are not used any more in my code.Bulbul
@HenkWiersema Did you read the first sentence of this answer? Where it says "... other ways"? Did you read the second sentence about "... mark all is pressed"? That is not a few clicks. What was the point of your comment on an answer that is over 3 years old?Chirpy
B
2

Found the answer here.

  • Download and install the python script plugin
  • Plugins --> Python script --> New script
  • Name it SelectedTextCountIntoStatusBar.py
  • Paste this, save and quit:

def callback_sci_UPDATEUI(args): if args['updated'] & UPDATE.SELECTION: matches = [] if editor.getTextLength() < 100000: # don't search "big" files if editor.getSelections() == 1 and not editor.getSelectionEmpty(): try: editor.research(r'\Q' + editor.getSelText() + r'\E', lambda m: matches.append(1)) except: matches = [] l = len(matches) notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, ' ' if l == 0 else '{} occurrence(s) of selected text'.format(l)) editor.callback(callback_sci_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI])

  • Plugins --> Python script --> Scripts --> SelectedTextCountIntoStatusBar
  • Double-click on a word
  • The number of occurrences is in the status bar.
Bulbul answered 22/7, 2018 at 12:39 Comment(1)
wow, this is such a useful plugin.Mutualize
D
1

As of now, Notepad++ does not show the count for smart highlighting (i.e. highlighting words by double-clicking on one occurrence).

... but how about having the count directly be shown somewhere?

As an alternative:

  • open the Find window (Search > Find...)
  • Navigate to the Mark tab
  • Type the word in the Find What: input area
  • Click Mark All

This will mark all the occurrences as well show the count of matches in the status bar.

BTW: Can smart highlighting be activated in a different manner than double clicking?

There is another alternative for smart highlighting using Style Token which is available from the right-click context menu. Watch the animated tutorial below:

enter image description here

Dwt answered 24/7, 2018 at 15:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.