Editor_FindReplace

Searches or replaces a string. You can use this inline function or explicitly send the EE_FIND_REPLACE message.

HRESULT Editor_FindReplace( HWND hwnd, UINT64 nFlags, LPCWSTR pszFind, LPCWSTR pszReplace, UINT64* pnCount, UINT64* pnMatchedLines );

Parameters

hwnd

Specifies the window handle of the view or frame of EmEditor.

nFlags

[in] Specifies a combination of the following values.

Value

Meaning

FLAG_FIND_AROUND

Moves to start/end of the text.

FLAG_FIND_BOOKMARK

Sets bookmarks on lines where the string is matched.

FLAG_FIND_CASE

Matches cases.

FLAG_FIND_COUNT

Counts the occurrences of the matched string.

FLAG_FIND_EMBEDDED_NL

Matches embedded newlines in CSV documents and does not match other newlines.

FLAG_FIND_ESCAPE

Uses escape sequences.

FLAG_FIND_EXTRACT

Extracts matched lines to a new document.

FLAG_FIND_FUZZY

Uses fuzzy matching.

FLAG_FIND_NEXT

Searches the string downward from the cursor position. If this flag is not set, searches the string upward.

FLAG_FIND_NO_OVERLAP

Does not match overlapping strings when finding a next or previous match.

FLAG_FIND_NO_PROMPT

Suppresses displaying a dialog box even if no string is found.

FLAG_FIND_ONLY_WORD

Searches only words.

FLAG_FIND_OPEN_DOC

Searches all open documents in the same frame window.

FLAG_FIND_REG_EXP

Uses a regular expression.

FLAG_FIND_REGEX_BOOST

Uses Boost.Regex as the regular expression engine.

FLAG_FIND_REGEX_ONIGMO

Uses Onigmo as the regular expression engine.

FLAG_FIND_SAVE_HISTORY

Saves the searched string for repeated search.

FLAG_FIND_SELECT_ALL

Selects all matched strings.

FLAG_FIND_SEPARATE_CRLF

Treats CR and LF separately.

FLAG_FIND_SEL_ONLY

Searches only in the selection.

FLAG_REPLACE_ALL

Replaces all occurrences.

FLAG_REPLACE_SEL_ONLY

Replaces only in the selection when specified with FLAG_REPLACE_ALL.

pszFind

[in] Specifies a string to search for.

pszReplace

[in] Specifies a string to replace with. This value must be NULL if not replacing.

pnCount

[out] Specifies a pointer to the variable that receives the number of occurrences when nFlags includes FLAG_FIND_COUNT, FLAG_FIND_BOOKMARK, FLAG_FIND_SELECT_ALL, FLAG_FIND_EXTRACT or FLAG_FIND_FILTER.

pnMatchedLines

[out] Specifies a pointer to the variable that receives the number of matched lines when nFlags includes FLAG_FIND_COUNT, FLAG_FIND_BOOKMARK, FLAG_FIND_SELECT_ALL, FLAG_FIND_EXTRACT or FLAG_FIND_FILTER.

Return Values

Returns S_OK if the searched string is found, S_FALSE if not found. The return value is a negative value if an error occurs. The negative value includes E_ABORT if a user cancels the search, and E_FAIL if a fatal error occurs.

Version

Supported on Version 15.7 or later.