JetBrains Rider 2024.1 Help

Scopes and file colors

A scope the Scope icon is a group of files and folders in a solution. You can use scopes to visually distinguish solution items in different IDE views and to limit the range of specific operations.

Scopes are designed to logically organize files in your solution: test sources can go to the test-related scope, and production code can be associated with the scope of production files. These logical chunks make your solution easier to manage.

JetBrains Rider comes with a set of predefined scopes, but you can also create custom scopes. There, you can include any files and folders. For example, a custom scope can include only those files in the solution for which you are responsible.

There are 2 types of scopes: local and shared.

  • Local scopes are stored in the IDE configuration directory, that is why they are not shared through VCS and are not available to other members of your team.

  • Shared scopes are added to a VCS so that people who work on a solution can use the same scopes. These scopes are stored together with the solution in the scopes folder under .idea. Each scope is saved as a file with the .xml extension (for example: MySolution/.idea/scopes/shared-scope.xml).

Using shared scopes makes sense if your solution is under version control. If you don't use a VCS, local scopes will be sufficient to cover your needs.

Define a new scope

In JetBrains Rider, there's a set of predefined scopes, but you can also define your own scopes.

  1. Press Ctrl+Alt+S to open settings and then select Appearance & Behavior | Scopes.

  2. Click the Add Scope button (the Add Scope button) and select what kind of scope you want to define: local or shared.

    You can change the state of the selected scope (local or shared) later using the Share through VCS checkbox.

    Creating a new scope: selecting between a shared and a local scope
  3. In the dialog that opens, name the new scope and click OK.

  4. Add files to the new scope. Select the necessary items in the solution tree and click one of the options located on the right from the tree:

    • Include: include the selected items. If you are including a folder, this action adds only the files located inside this folder. All nested subfolders and their contents will not be included.

    • Include Recursively: include the selected folder together with the nested subfolders and their contents.

    • Exclude: exclude the selected items from the scope. If you are excluding a folder, this action removes only the files located inside this folder. All nested subfolders and their contents will remain in the scope.

    • Exclude Recursively: exclude the selected folder together with the nested subfolders and their contents.

    As you add files to the scope, JetBrains Rider creates an expression and displays it in the Pattern field.

    Instead of using the buttons, you can also type a pattern in the Pattern field manually using the scope language syntax reference.

  5. Apply the changes and close the dialog.

Files and folders displayed for the selected scope are shown in different colors to help you understand what is included and what is not:

  • the green color sample Files and folders included in the scope.

  • the dark blue color sample Folders that contain both excluded and included files and folders.

  • the black color sample Files and folders that are excluded from the selected scope.

Predefined scopes

JetBrains Rider provides a set of predefined scopes. The IDE adds files to these scopes automatically based on the information about them. Note that these scopes cannot be modified.

List of predefined scopes

  • All Changed Files: includes all the recently changed files.

  • Scratches and Consoles: includes all files from the Scratches and Consoles directory located in the Explorer tool window .

  • Recently Viewed Files and Recently Changed Files: includes the last 50 files that you have opened or modified in the editor. You can change the number of recent files in the Limits area on the Editor | General page of the Settings/Preferences dialog (Ctrl+Alt+S) .

  • Current File: corresponds to the file that is currently active in the editor.

  • Selected Files: includes the selected files that are selected in a tool window (for example, in the Solution Explorer).

  • Local Changes (These scopes appear if VCS integration is enabled)

    • All Changed Files: includes the modified files with changes that are not yet added to VCS from all changelists.

    • Default Changelist: includes the modified files with changes that are not yet added to VCS from the Default changelist.

    • 'Changelist name': includes the modified files with changes that are not yet added to VCS from a specific custom changelist.

Associate scopes with colors

Files that belong to different scopes can be highlighted in different colors in search results, in editor tabs, and in the Solution Explorer.

Scope highlighting in the editor tabs and search results

To each scope, you can assign its own color. For example, you can assign a color to the Open Files scope and configure the IDE to show this color in the Explorer tool window . In this case, the files that you are currently working with in the editor will be colored in the project tree. This makes solution navigation faster and simpler. Note that file colors work only in association with scopes.

Similarly to scopes, color associations can be local and shared.

  • Local colors are only visible to you and are not shared through VCS.

  • Shared colors are placed under version control so that people who work on a solution can use the same color associations. They are stored in the solution folder under .idea in the fileColors.xml file (for example: MySolution/.idea/fileColors.xml).

Create a new color association

  1. Press Ctrl+Alt+S to open settings and then select Appearance & Behavior | File Colors.

  2. Make sure that the Enable file colors checkbox is selected, and then choose where you want to use the colors: select Use in editor tabs or Use in project view.

  3. Click the Add button (the Add icon) and select the scope for which you want to configure a color.

    You can select one of the pre-defined scopes or use a custom scope.

  4. Click the arrow the right arrow icon next to the necessary scope and select a color from the list that opens.

    To configure your own color, click Custom.

  5. To edit a color, click the cell that corresponds to the necessary scope in the Color column and select a new color from the list.

  6. To share a color through a VCS, select the checkbox on the corresponding line in the Share through VCS column. If the checkbox is cleared, the color will be used locally.

  7. Apply the changes and close the dialog.

If a file is included in several scopes, the order of the scopes becomes important: JetBrains Rider processes the scopes from the top to the bottom starting from local scopes. It means that the IDE will apply the color of the last scope in the list to such a file.

You can change the order of the scopes if you want JetBrains Rider to process color associations in a different order.

Change the order of scopes

  1. Press Ctrl+Alt+S to open settings and then select Appearance & Behavior | Scopes.

  2. Select the scope that you want to move and click the Move Up (the Move Up button) or Move Down (the Move Down button) button. Alternatively, press Alt+Up or Alt+Down.

  3. Apply the changes and close the dialog.

Scope language syntax reference

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

Last modified: 26 May 2024