Sublime Blog

Sublime Text 3 File Indexing

Some of the core features in Sublime Text 3 are Goto Definition and Goto Symbol in Project. Both of these work by indexing the files in the current project to determine where each symbol is defined.

When indexing is in progress, several low priority background processes will be launched to do the work, and a progress indicator will be shown on the status bar. In general, even for large projects, indexing should take only a few seconds, and be unobtrusive.

However, things can go wrong, so if you're seeing high CPU usage in Sublime Text 3, then file indexing is the first thing to look at. There are two things that can cause excess CPU usage from the indexing:

  • A corrupted index. Various events can cause the index itself to become corrupted, and when this happens, Sublime Text will do the indexing work, but be unable to write the results to disk, so it'll start again in the near future. The next build of Sublime Text will handle this situation more gracefully, but in the mean time you can check this for yourself: if the index is corrupted, there will be a log message in the console (accessible from the View/Show Console menu), which indicates which directory needs to be deleted to reset the index.
  • Some files. File indexing works by applying syntax highlighting rules to each file, and then extracting everything that looks like a symbol. The syntax highlighting rules are regex based, and some combinations of rules and files can cause the parsing to take a long time. See below to find out what's going on, and then consider adding the files to the index_exclude_patterns setting.

To see when files are being indexed, you can enter sublime.log_indexing(True) in Sublime Text's console. This will trigger Sublime Text to start logging relevant information whenever it indexes files.

To disable file indexing altogether, you can set the index_files setting to false.

Jon Skinner