// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page creator-editor-finding.html
    \if defined(qtdesignstudio)
    \previouspage qtquick-text-editor.html
    \else
    \previouspage creator-how-tos.html
    \endif

    \ingroup creator-how-to-search
    \ingroup studio-how-to-search

    \title Search in current file

    The incremental search highlights the matching strings in the editor while
    you type.

    To search through the currently open file:

    \list 1

        \li Press \key {Ctrl+F} or go to \uicontrol Edit >
            \uicontrol {Find/Replace} > \uicontrol {Find/Replace}.

        \li In \uicontrol Find, enter the text you are looking for.

            \image qtcreator-find-from-current-file.webp {Search hits highlighted in editor}

            All occurrences of the text are highlighted in the editor as you
            type.

        \li To go to the next occurrence, select \inlineimage icons/next.png
            (\uicontrol {Find Next}), or press \key F3.

        \li To go to the previous occurrence, select \inlineimage icons/prev.png
            (\uicontrol {Find Previous}), or press \key {Shift+F3}.

        \li To select all found occurrences in a file, select
            \uicontrol {Select All}.

    \endlist

    \note Select text before selecting \uicontrol {Find/Replace} to search only
    from the selection.

    \section1 Set search criteria

    To restrict the search in the \uicontrol Find box, select
    \inlineimage icons/qtcreator-new-search-icon.png and set search criteria:

    \list

        \li To make your search case sensitive, select
            \uicontrol {Case Sensitive}.

        \li To search only whole words, select \uicontrol {Whole Words Only}.

        \li To search using \l{QRegularExpression}{regular expressions}, select
            \uicontrol {Use Regular Expressions}. Regular expressions used in \QC
            are modeled on Perl regular expressions

    \endlist

   \section1 Replace text

    To replace occurrences of the existing text, enter the new text in
    \uicontrol {Replace with}.

    \list
        \li To replace the selected occurrence, select \uicontrol {Replace}.
        \li To replace the selected occurrence and move to the next one,
            select \uicontrol {Replace & Find}.
        \li To replace all occurrences in the file, select
            \uicontrol {Replace All}.
    \endlist

    \section1 Preserve case when replacing

    To preserve the case of the original text when replacing, select
    \inlineimage icons/qtcreator-new-search-icon.png and then select
    \uicontrol {Preserve Case when Replacing}. You cannot use this option
    together with \uicontrol {Use Regular Expressions}.

    The case of the of the occurrence is preserved according to the following
    rules:

    \list

        \li All upper-case occurrences are replaced with the upper-case new
            text.
        \li All lower-case occurrences are replaced with the lower-case new
            text.

        \li Capitalized occurrences are replaced with the capitalized new text.

        \li Other occurrences are replaced with the new text as entered.

        \li If an occurrence and the new text have the same prefix or suffix,
            the case of the prefix and suffix are preserved, and the
            other rules are applied to the rest of the occurrence.

    \endlist

    \section1 Highlight search hits

    The locations of search hits, breakpoints, and bookmarks in your document
    are highlighted on the editor scroll bar. To turn highlighting off, select
    \preferences > \uicontrol {Text Editor} >
    \uicontrol Display > \uicontrol {Highlight search results on the scrollbar}.

    \image qtcreator-options-text-editor-display.png {Text Editor Display preferences}

    \section1 Search globally

    Select \uicontrol Advanced to open the \uicontrol {Search Results} view where
    you can search in currently open projects or files on the file system. Or,
    search for symbols to refactor code.

    \if defined(qtcreator)
    \sa {Search}{How To: Search}
    \else
    \sa {Search in projects or file systems}
    \endif

    \sa {Search Results View}
*/

/*!
    \page creator-how-to-advanced-search.html
    \if defined(qtdesignstudio)
    \previouspage qtquick-text-editor.html
    \else
    \previouspage creator-how-tos.html
    \endif

    \ingroup creator-how-to-search
    \ingroup studio-how-to-search

    \title Search in projects or file systems

    The search scope and search criteria determine where \QC looks for the search
    string, how it matches the string with text, and which results it shows.

    \section1 Search in all projects

    \list 1
        \li Press \key {Ctrl+Shift+F} or go to \uicontrol Edit >
            \uicontrol {Find/Replace} > \uicontrol {Advanced Find} >
            \uicontrol {Open Advanced Find}.
        \li In \uicontrol Scope, select \uicontrol {All Projects}.
            \image qtcreator-search-all-projects.webp {Search Results view}
        \li In \uicontrol {Search for}, enter the string you are looking for.
        \li Select options to make the  search case sensitive, search only whole
            words, or use regular expressions.
        \li In \uicontrol {File pattern}, specify file patterns to
            restrict the search to files that match the pattern. For example, to
            search for a string only in \c {.cpp} and \c {.h} files, enter
            \c {*.cpp,*.h}.
        \li In \uicontrol {Exclusion pattern}, specify file patterns
            to omit files from the search.
        \li Select \uicontrol Search.
    \endlist

    \if defined(qtcreator)
    If you cannot find some files, see \l{Specify project contents} for
    how to declare them as a part of the project.
    \endif

    \section1 Search in the file system

    In addition to the options available for searching from all projects, you can
    select the search engine to use and the directory to search in.

    \list 1
        \li In \uicontrol Scope, select \uicontrol {Files in File System}.
            \image qtcreator-search-file-system.webp {Search Results view}
        \li In \uicontrol {Search for}, enter the string you are looking for.
        \li In \uicontrol {Search engine}, select the search engine to use:
            \list
                \li Select \uicontrol Internal to use the \QC search
                    engine.
                \li Select \uicontrol {Git Grep} to use Git to only
                    search tracked files in the Git work tree. To
                    restrict the search to the HEAD, a tag, a local or
                    remote branch, or a commit hash, enter a reference.
                    Leave the field empty to search through the file
                    system.
                \if defined(qtcreator)
                \li Select \uicontrol {Silver Searcher} to use the
                    experimental Silver Searcher plugin.
                \endif
            \endlist
        \li In \uicontrol Directory, select the directory to search in.
            Select \uicontrol Browse to locate the directory or
            \uicontrol Current to search in the directory where the currently
            active file is.
        \li Select \uicontrol Search.
    \endlist

    \section1 Search and replace

    To replace occurrences of the existing text:

    \list 1
        \li Select \uicontrol {Search & Replace}.
        \image qtcreator-search-results-reg-exp.webp {Search results when searching and replacing}
        \li Enter the new text in \uicontrol {Replace with}.
        \li Select \uicontrol Replace.
    \endlist

    To preserve the case of the original text when replacing,
    select \uicontrol {Preserve case}. The rules listed in
    \l {Preserve case when replacing} apply here as well.

    \if defined(qtcreator)
    \sa {Search}{How To: Search}, {Find symbols}, {Turn on Silver Searcher}
    \endif

    \sa {Search in current file}, {Search Results View}
*/
