Show count of occurrences when smart highlighting in Notepad++

那年仲夏 提交于 2019-12-03 10:26:16
AdrianHHH

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.

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.

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:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!