Scopes
A scope is a filtered subset of files and directories in your project. When you enable the Scopes view, you limit operations like search and code inspection to the selected scope. This section describes how to configure scopes and coloring of the files belonging to these scopes.
Create a new scope
-
In the Settings/Preferences dialog (Ctrl+Alt+S), go to .
-
Click , select Local or Shared from the list, and specify the name of the scope.
Local scopes are intended for personal use only and are stored in your workspace. Default location: %HOMEPATH%\.<product><version>\config\projects\<project_name>\.idea\workspace.xml
Shared scopes are defined for the current project and accessible for the team members via VCS. Default location: %HOMEPATH%\.<product><version>\config\projects\<project_name>\.idea\scopes\
Configure a list of items in a scope
-
In the Settings/Preferences dialog (Ctrl+Alt+S), go to and select the scope that you want to configure.
-
To define a pattern for the scope, perform one of the following actions:
To include files and directories in the scope, select files and directories and press Include or Include Recursively (with subdirectories) buttons. To exclude a file or a directory, use Exclude or Exclude Recursively. DataGrip creates an expression and displays it in the Pattern field.
Specify a pattern in the Pattern field manually, using the scope language syntax.
Click Apply.
Filter files in the attached directory by the file extension
Navigate to Files | Settings | Appearance & Behavior | Scopes, click the Show Options Menu icon () and select Edit Scopes.
Select a scope or create a new one.
In the Pattern field, type the following code: file:*.<file_extension>, where <file_extension> is a file extension that you want to use for a filter.
In the Files tool window, click the Files drop-down list and select the scope name that you created.
Associate file color with a scope
Files that belong to different scopes can be highlighted in different colors throughout the DataGrip's user interface: in navigation lists, in the editor tabs, in the Files tool window. This allows much faster and easier navigation in large projects.
Associate file color with a scope
Navigate to File | Settings | Appearance & Behavior | File Colors.
Click Add ().
In the Add Color Label dialog, select a scope and pick a color for it.
Click OK.
Define the area where you want to use scope colors. To define the area, select Use in Editor Tabs or Use in Project View checkboxes.
Select the accessibility level of the scope color association. To share the color association, click the Share icon(). The default location for file color associations is %HOMEPATH%\.<product><version>\config\projects\<project_name>\.idea\fileColors.xml
Apply changes.
Arrange the order of scopes
If some file is included into several scopes, the order of the scopes becomes important: DataGrip uses the color of the uppermost scope (shown in the Scopes settings page) to highlight such file. Of course, you can change the order of the scopes, and thus the resulted highlighting.
Arrange the order of scopes
Navigate to Files | Settings | Appearance & Behavior | Scopes.
Select a scope that you want to move.
To change the order, click Move Up () or Move Down icons ().
Click Apply.
Reference for the scope language syntax
Description | Pattern | Example |
---|---|---|
Include a single file by its name | file:<directory>/<file> | file:databases/create_schema.sql |
Include a set of all files in a directory, without subdirectories | file:<directory>/* | file:databases/mysql-db/* |
Include a set of all files in a directory with subdirectories | file:<directory>//* | file:databases/mysql-db//* |
Include a file by its name from the certain project | file[project_name]:<directory>/<file> | file[default]:databases/create_schema.sql |
Possible logical operators &&·(AND), ||·(OR), !·(NOT). | file[project_name]:<directory>&&!file:<directory> | file[default]:databases/*&&!file:databases/create_schema.sql |