Navigating through everything

Sublime is known for its ability to quickly move between and around files and lines. In this section, we are going to master how to navigate our code quickly and easily.

Go To Anything

We already learned how to use the Go To Anything feature, but it can do more than just searching for filenames. We can conduct a fuzzy search inside a "fuzzily found" file. Really? Yeah, we can. For example, we can type the following inside the Go To Anything window:

isl#wld

This will make Sublime perform a fuzzy search for wld inside the file that we found by fuzzy searching isl; it can thus find the word world inside a file named island.

We can also perform a fuzzy search in the current file by pressing Ctrl +; in Windows or Linux and command + P, # in OS X. It is very common to use fuzzy search inside HTML files because it immediately shows all the elements and classes that match, accelerating navigation.

Symbol search

Sometimes we want to search for a specific function or class inside the current file. With Sublime we can do it simply by pressing Ctrl + R on Windows or Linux and command + R on OS X.

Symbol search

Projects

A project is a group of files and folders. To save a project we just need to add folders and files to the sidebar, and then from the menu, we navigate to Project | Save Project As…

The saved file is our projects data, and it is stored in a JSON formatted file with a .sublime-project extension. The following is a sample project file:

{
    "folders":
    [
        {
            "path": "src",
            "follow_symlinks": true
        },
        {
            "path": "docs",
            "name": "Documentation",
            "file_exclude_patterns": ["*.xml"]
        }
    ],
    "settings":
    {
        "tab_size": 6
    },
    "build_systems":
    [
        {
            "name": "List",
            "shell_cmd": "ls -l"
        }
    ]
}

As we can see in the preceding code, there are three elements written as JSON arrays.

Folders

Each folder must have a valid folder path that can be absolute or relative to the project directory, which is where the project file is. A folder can also include the following keys:

  • name: This is the name that will be shown on the sidebar
  • file_execlude_pattern: This folder will exclude all the files matching the given Regular Expression
  • file_include_pattern: This folder will include only files matching the given Regular Expression
  • folder_execlude_pattern: This folder will exclude all subfolders matching the given Regular Expression
  • folder_include_pattern: This folder will include only subfolders matching the given Regular Expression
  • follow_symlinks: This will include symlinks if set to true

Settings

The project-specific settings array will contain all the settings that we want to apply only to this project. These settings will override our global user settings.

Build systems

In an array of build system definitions, we must specify a name for each definition; these build systems will then be specified in Tools | Build Systems.

Tip

For more information about build systems, please visit http://sublimetext.info/docs/en/reference/build_systems.html.

Navigating between projects

To switch between projects quickly, we can press Ctrl + Alt + P in Windows or Linux and Control + command + P in OS X.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset