1

In Notepad++, when select a word by double click or by cursor select, all other occurrences of the word will be selected.

What is the API to call to achieve this in Win32 (C++) platform.

milesma
  • 1,561
  • 1
  • 15
  • 37
  • In my version of SciTE ( Version 3.6.0 compiled for GTK+ 3.16.7 ) on Linux there is an item in the [search] menu stating [selection add each] which does exectly what you want. I would be suprised if it doesn't exist in the Win32 version. – Claudio Sep 10 '20 at 07:01
  • https://www.scintilla.org/PaneAPI.html tells: editor:MultipleSelectAddEach() -- Add each occurrence of the main selection in the target to the set of selections. If the current selection is empty then select word around caret. Is this what are you looking for? – Claudio Sep 10 '20 at 07:08

3 Answers3

0

Please checkout the "MatchMarker.cxx" file in SciTE source.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 27 '21 at 00:02
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30185789) – kian Oct 27 '21 at 12:53
0

You can set

highlight.current.word=1

in SciTEUser.properties file which can be accessed from the menu Options > Open User Options File.

More options refers to https://www.scintilla.org/SciTEDoc.html .

user257122
  • 31
  • 4
0

I have added my own approach to highlighting all occurrences of the current selection...

First, I added these functions to my SciTEstartup.lua script:

function clearOccurrences()
    scite.SendEditor(SCI_SETINDICATORCURRENT, 0)
    scite.SendEditor(SCI_INDICATORCLEARRANGE, 0, editor.Length)
end

function markOccurrences()
    if editor.SelectionStart == editor.SelectionEnd then
        return
    end
    clearOccurrences()
    scite.SendEditor(SCI_INDICSETSTYLE, 0, INDIC_ROUNDBOX)
    scite.SendEditor(SCI_INDICSETFORE, 0, 255)
    local txt = GetCurrentWord()
    --print "in markOccurrences()..."
    local occurrences = 0
    local flags = SCFIND_WHOLEWORD
    local s,e = editor:findtext(txt,flags,0)
    while s do
        scite.SendEditor(SCI_INDICATORFILLRANGE, s, e - s)
        occurrences = occurrences + 1
        s,e = editor:findtext(txt,flags,e+1)
    end
    print("found "..tostring(occurrences).." occurrences")
end

Then I assigned Shortcut Keys to these functions in the ScitEUser.properties files assigning highlight occurrences with "Ctrl-." and clearing with "Ctrl-,"

# from http://lua-users.org/wiki/SciteMarkWord
command.name.37.*=markOccurrences
command.mode.37.*=subsystem:lua,savebefore:no
command.37.*=markOccurrences
command.shortcut.37.*=Ctrl+.

command.name.38.*=clearOccurrences
command.mode.38.*=subsystem:lua,savebefore:no
command.38.*=clearOccurrences
command.shortcut.38.*=Ctrl+,
dstelow
  • 573
  • 7
  • 10