aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/editors/creator-search.qdoc
blob: c3bd9e1fa22171785a749eab798f47abb6ec21e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// 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 studio-finding.html
    \nextpage creator-how-to-advanced-search.html
    \else
    \previouspage creator-how-tos.html
    \endif

    \ingroup creator-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 creator-editor-finding.html
    \nextpage creator-how-to-rename-symbols.html
    \else
    \previouspage creator-how-tos.html
    \endif

    \ingroup creator-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}
    \else
    \sa {Search in current file}
    \endif

    \sa {Search Results View}
*/