aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/editors/creator-search.qdoc
blob: 8c79e59700eb19bc11d4c20545e3142cf8845bd7 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

/*!
    \previouspage creator-finding-overview.html
    \page creator-editor-finding.html
    \nextpage creator-editor-locator.html

    \title Finding and Replacing

    To search through the currently open file:

    \list 1

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

        \li Enter the text you are looking for.

            If the text is found, all occurrences are highlighted as you type.

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

    \endlist

    You can restrict the search in the \uicontrol Find field by selecting one
    or several 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 regular expressions, select
            \uicontrol {Use Regular Expressions}. Regular expressions used in \QC
            are modeled on Perl regular expressions. For more information on
            using regular expressions, see the documentation for the
            QRegularExpression Class.

    \endlist

    \note If you have selected text before selecting \uicontrol {Find/Replace}, the
    search is conducted within the selection.

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

    \list

        \li To replace the selected occurrence and move to the next one,
            click \uicontrol {Find Next} or press \key {Ctrl+=}.

        \li To replace the selected occurrence and move to the previous one,
            click \uicontrol {Find Previous}.

        \li To replace all occurrences in the file, click
            \uicontrol {Replace All}.

    \endlist

    The \uicontrol {Preserve Case when Replacing} option can be selected to
    preserve the case of the original text when replacing. This option is not
    compatible with the \uicontrol {Use Regular Expressions} search option, and will
    thus be disabled when regular expressions are used. When the option is used,
    the case of the occurrence will be conserved, 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,
            then the case of the prefix and/or suffix are preserved, and the
            other rules are applied on the rest of the occurrence only.

    \endlist

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

    \section1 Advanced Search

    To search through projects, files on a file system or currently open files:

    \list 1

        \li Press \key {Ctrl+Shift+F} or select \uicontrol Edit >
            \uicontrol {Find/Replace} > \uicontrol {Advanced Find} >
            \uicontrol {Open Advanced Find}.

        \li Select the scope of your search:

            \list

                \li \uicontrol {All Projects} searches from all currently open
                    projects.

                    \image qtcreator-search-allprojects.png

                \li \uicontrol {Current Project} searches from the project you
                    are currently editing.

                \li \uicontrol {Files in File System} recursively searches from
                    the selected directory.

                    \image qtcreator-search-filesystem.png

                    In the \uicontrol {Search engine} field, 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. For more
                            information, see \l{Enabling Silver Searcher}.
                        \endif

                    \endlist

                \li \uicontrol {Current File} searches only from the current
                    file.

                \li \uicontrol {Open Documents} searches from all open files.

                \if defined(qtcreator)
                \li \uicontrol {Clang Query Project} explores the Clang abstract
                     syntax tree (AST) using AST matcher expressions. For more
                     information, see \l{Exploring Clang AST}.
                 \endif

            \endlist

        \li In the \uicontrol {File pattern} field, 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 the \uicontrol {Exclusion pattern} field, specify file patterns
            to omit files from the search.

        \li Enter the text you are looking for and click \uicontrol Search.

            \image qtcreator-searchresults.png

             A list of files containing the searched text is displayed in the
            \uicontrol {Search Results} pane.

            \list

                \li To see all occurrences in a file, double-click the file name
                    in the list.

                \li To go to an occurrence, double-click it.

                \li To repeat the search after you have made changes to the
                    listed files, for example, select
                    \uicontrol {Search Again}.

            \endlist

    \endlist

    The search results are stored in the search history from which you can
    select earlier searches.

    To clear the search results, select the \inlineimage clean_pane_small.png
    (\uicontrol Clear) button.

    To start a new search, select the \inlineimage qtcreator-new-search-icon.png
    (\uicontrol {New Search}) button.

    \note You can use \uicontrol {Advanced Find} also to search for symbols. For
    more information, see
    \if defined(qtcreator)
    \l{Finding Symbols}.
    \else
    \l{Finding QML Types}.
    \endif

    \if defined(qtcreator)
    \section1 Enabling Silver Searcher

    You can use Silver Searcher as a search engine in \QC if you install
    Silver Searcher on the development PC and enable the experimental plugin.

    To use Silver Searcher:

    \list 1

        \li Download and install Silver Searcher from
            \l {https://geoff.greer.fm/ag/}{The Silver Searcher} or
            \l {https://github.com/ggreer/the_silver_searcher}{GitHub}.

            You might have to build Silver Searcher from sources for some
            platforms.

        \li Select \uicontrol Help > \uicontrol {About Plugins} >
            \uicontrol {Utilities} > \uicontrol {SilverSearcher} to enable the
            plugin.

        \li Select \uicontrol {Restart Now} to restart \QC and load the plugin.

        \li When searching, select \uicontrol {Silver Searcher} in the
            \uicontrol {Search engine} field.

    \endlist

    \section1 Exploring Clang AST

    You can use the experimental Clang Refactoring plugin to explore the Clang
    AST using AST matcher expressions. For more information about constructing
    matcher expressions, see
    \l {http://clang.llvm.org/docs/LibASTMatchersReference.html}
    {AST Matcher Reference}.

    To explore the AST:

    \list 1

        \li Select \uicontrol Help > \uicontrol {About Plugins} > \uicontrol C++
            > \uicontrol {ClangRefactoring} to enable the plugin.

        \li Select \uicontrol {Restart Now} to restart \QC and load the plugin.

        \li When searching, select \uicontrol {Clang Query Project} in the
            \uicontrol {Scope} field.

        \li Enter an AST matcher expression in the \uicontrol {Search for}
            field.

    \endlist

    You can view the results of the query as links to code positions in the
    \uicontrol {Search Results} output pane.
    \endif
*/