Riferimento per la sintassi
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina fornisce informazioni dettagliate sui filtri, gli operatori, le opzioni di sintassi e le scorciatoie da tastiera supportati per la ricerca nel codice.
Filtri supportati
La tabella seguente elenca i filtri che puoi utilizzare durante la ricerca del codice.
Filtro |
Altre opzioni |
Descrizione |
Esempio |
case:yes |
case:y |
Rendi la ricerca sensibile alle maiuscole. Per impostazione predefinita, le ricerche non sono sensibili alle maiuscole.
Se raggruppi più termini di ricerca, questo filtro viene ereditato da
tutti i gruppi secondari. |
case:yes Hello World |
class: |
|
Cerca il nome di un corso. |
class:MainClass |
comment: |
|
Cercare all'interno dei commenti. |
comment:bug |
content: |
|
Cerca solo nei contenuti dei file. Sono esclusi i nomi dei file. |
content:hello |
file: |
filepath:
path:
f: |
Cerca un file in base al nome o al percorso. |
file:test.js |
function: |
func: |
Cerca il nome di una funzione. |
function:print |
lang: |
language: |
Cercare risultati utilizzando una lingua specifica. |
lang:java test |
pcre:yes |
|
Utilizza espressioni regolari compatibili con Perl.
Utile per la ricerca su più righe. |
pcre:yes @Provides\s+double |
symbol: |
|
Cerca un simbolo specifico. |
symbol:immutable |
usage: |
|
Esegui la ricerca escludendo commenti e stringhe letterali. |
usage:map |
opzioni di lingua
La tabella seguente elenca i linguaggi di programmazione di uso comune supportati dal filtro
lang:
. Se applicabile, è possibile utilizzare un alias per il valore.
Lingua |
Valore lang: |
Alias |
C++ |
c++ |
cpp , cc , cxx |
C |
c |
|
Java |
java |
|
Kotlin |
kotlin |
kt , kts |
Python |
python |
py |
JavaScript |
javascript |
js |
Go |
go |
golang |
JSON |
json |
|
HTML |
html |
angular |
Objective-C++ |
objectivec++ |
|
Objective-C |
objectivec |
objc |
Markdown |
markdown |
md |
AppleScript |
applescript |
|
C# |
c# |
csharp |
CSS |
css |
|
CSV |
csv |
|
curl |
curl |
|
Dart |
dart |
|
Django |
django |
|
JSP |
jsp |
|
Perl |
perl |
|
PHP |
php |
|
PowerShell |
powershell |
|
Ruby |
ruby |
|
Rust |
rust |
rs |
shell |
shell |
bash , sh |
SHTML |
shtml |
|
SQL |
sql |
|
Swift |
swift |
|
Tcl |
tcl |
|
XML |
xml |
|
XSLT |
xslt |
|
YAML |
yaml |
|
Operatori supportati
La tabella seguente elenca gli operatori che puoi utilizzare durante la ricerca di codice.
Opzioni di sintassi aggiuntive
Per la ricerca di codice sono supportate le seguenti opzioni di sintassi aggiuntive.
Opzione |
Descrizione |
(search_expression) |
Raggruppa più termini. Per ulteriori informazioni, consulta
Raggruppamento dei termini di ricerca. |
- |
Esclude il termine dai risultati di ricerca. |
\ |
Esegue l'escape dei caratteri speciali come . , \
o ( . |
"search_expression" |
Esegui una ricerca letterale senza interpretare la query di ricerca come un'espressione regolare. |
Scorciatoie da tastiera supportate
Per visualizzare le scorciatoie da tastiera disponibili in Code Search, digita ?
.
La tabella seguente elenca le scorciatoie da tastiera che puoi utilizzare durante la ricerca
del codice.
Chiave |
Azione |
h |
Mostra la cronologia delle revisioni del file. |
q |
Attiva/disattiva il riquadro inferiore. |
b |
Mostra o nascondi il livello di attribuzione. |
f |
Mostra la barra di ricerca. |
/ |
Sposta lo stato attivo sulla casella di ricerca. |
o |
Sposta lo stato attivo sul browser della struttura. |
t |
Sposta lo stato attivo sull'albero delle directory. |
l |
Apre il menu a discesa Link. |
lp |
Copia il percorso del file nel menu a discesa Link. |
lh
|
Copia il link alla versione HEAD del file
nel menu a discesa Link. |
lr
|
Copia il link alla versione corrente del file
e alla riga corrente nel menu a discesa Link. |
.
|
Nella casella di ricerca, cerca codice o file nella directory corrente. |
j |
Seleziona il risultato successivo nei risultati di ricerca. |
k |
Seleziona il risultato precedente nei risultati di ricerca. |
x |
Mostra i riferimenti incrociati per i simboli. |
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-28 UTC.
[null,null,["Ultimo aggiornamento 2025-08-28 UTC."],[[["\u003cp\u003eCode Search allows you to search for code using filters like \u003ccode\u003elang:\u003c/code\u003e, \u003ccode\u003efile:\u003c/code\u003e, and \u003ccode\u003eclass:\u003c/code\u003e to refine your results by language, filename, or class name respectively.\u003c/p\u003e\n"],["\u003cp\u003eYou can use operators like \u003ccode\u003eAND\u003c/code\u003e and \u003ccode\u003eOR\u003c/code\u003e to combine search terms, along with additional syntax options for grouping, excluding, and escaping characters within your queries.\u003c/p\u003e\n"],["\u003cp\u003eCode Search supports keyboard shortcuts for actions such as showing file history (h), toggling the bottom panel (q), and navigating search results (j/k).\u003c/p\u003e\n"],["\u003cp\u003eA wide variety of common programming languages are supported by Code Search, including but not limited to: Python, Java, JavaScript, C++, Go, and more, which can be specified using the \u003ccode\u003elang:\u003c/code\u003e filter and their respective values or aliases.\u003c/p\u003e\n"]]],[],null,["This page provides detailed information on the supported filters, operators,\nsyntax options, and keyboard shortcuts for Code Search.\n\nSupported filters\n\nThe following table lists the filters you can use when searching code.\n\n| Filter | Other options | Description | Example |\n|-------------|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|\n| `case:yes` | `case:y` | Make the search case sensitive. By default, searches are not case sensitive. If you are grouping multiple search terms, this filter is inherited by all child groups. | `case:yes Hello World` |\n| `class:` | | Search for a class name. | `class:MainClass` |\n| `comment:` | | Search within comments. | `comment:bug` |\n| `content:` | | Search only for file contents. This excludes filenames. | `content:hello` |\n| `file:` | `filepath:` `path:` `f:` | Search for a file by filename or path. | `file:test.js` |\n| `function:` | `func:` | Search for a function name. | `function:print` |\n| `lang:` | `language:` | Search for results by using a specific language. | `lang:java test` |\n| `pcre:yes` | | Use Perl compatible regular expressions. Useful for searching across lines. | `pcre:yes @Provides\\s+double` |\n| `symbol:` | | Search for a specific symbol. | `symbol:immutable` |\n| `usage:` | | Search while excluding comments and string literals. | `usage:map` |\n\nlang options\n\nThe table below lists the commonly used programming languages supported by the\n`lang:` filter. Where applicable, an alias can be used for the value.\n\n| Language | `lang:` value | Aliases |\n|---------------|----------------|--------------------|\n| C++ | `c++` | `cpp`, `cc`, `cxx` |\n| C | `c` | |\n| Java | `java` | |\n| Kotlin | `kotlin` | `kt`, `kts` |\n| Python | `python` | `py` |\n| JavaScript | `javascript` | `js` |\n| Go | `go` | `golang` |\n| JSON | `json` | |\n| HTML | `html` | `angular` |\n| Objective-C++ | `objectivec++` | |\n| Objective-C | `objectivec` | `objc` |\n| Markdown | `markdown` | `md` |\n| AppleScript | `applescript` | |\n| C# | `c#` | `csharp` |\n| CSS | `css` | |\n| CSV | `csv` | |\n| curl | `curl` | |\n| Dart | `dart` | |\n| Django | `django` | |\n| JSP | `jsp` | |\n| Perl | `perl` | |\n| PHP | `php` | |\n| PowerShell | `powershell` | |\n| Ruby | `ruby` | |\n| Rust | `rust` | `rs` |\n| shell | `shell` | `bash`, `sh` |\n| SHTML | `shtml` | |\n| SQL | `sql` | |\n| Swift | `swift` | |\n| Tcl | `tcl` | |\n| XML | `xml` | |\n| XSLT | `xslt` | |\n| YAML | `yaml` | |\n\nSupported operators\n\nThe following table lists the operators you can use when searching code.\n\n| Operator | Description |\n|----------|--------------------------------------------------------------------------------------------------------------|\n| `AND` | Logical \\`AND\\` operator. See [Using the AND operator](/code-search/user/and-operator) for more information. |\n| `OR` | Logical \\`OR\\` operator. See [Using the OR operator](/code-search/user/or-operator) for more information. |\n\nAdditional syntax options\n\nThe following additional syntax options are supported for searching code.\n\n| Option | Description |\n|-----------------------------------------------|------------------------------------------------------------------------------------------------------------------|\n| (\u003cvar translate=\"no\"\u003esearch_expression\u003c/var\u003e) | Groups multiple terms together. See [Grouping search terms](/code-search/user/group-terms) for more information. |\n| `-` | Excludes the term from search results. |\n| `\\` | Escapes special characters such as `.`, `\\`, or `(`. |\n| \"\u003cvar translate=\"no\"\u003esearch_expression\u003c/var\u003e\" | Perform a literal search without interpreting the search query as a regular expression. |\n\nSupported keyboard shortcuts\n\nTo see the keyboard shortcuts available in Code Search, type `?`.\n\nThe following table lists the keyboard shortcuts you can use when searching\ncode.\n\n| Key(s) | Action |\n|--------|-------------------------------------------------------------------------------------------------|\n| h | Show the file's revision history. |\n| q | Toggle the bottom panel. |\n| b | Show or hide the blame layer. |\n| f | Show the find bar. |\n| / | Change focus to the search box. |\n| o | Change focus to the outline browser. |\n| t | Change focus to the directory tree. |\n| l | Opens the Links drop-down. |\n| lp | Copies the file path in the Links drop-down. |\n| lh | Copies the link to the HEAD version of the file in the Links drop-down. |\n| lr | Copies the link to the current version of the file and the current line in the Links drop-down. |\n| . | While in the search box, search for code or files in the current directory. |\n| j | Select the next result in the search results. |\n| k | Select the previous result in the search results. |\n| x | Show cross references for symbols. |"]]