Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is file navigation in Sublime Text 2 so fast?

Tags:

sublimetext2

In Sublime Text 2, one can simply launch the editor, drag a folder into it, and press Ctrl+P to pretty much instantly open any file in that folder. As far as I can see the number of files in the folder doesn't matter, and it doesn't seem to perform any indexing at all. To be clear, I'm not talking about the speed of opening a specific file, I'm talking about the filtering function available that lets you filter between all files in a folder to find the one you want. For example: screenshot

In comparison, both Vim and Emacs pretty much need some sort of index in order to find files fast (FindFile for Vim, Ctags or Cscope for Emacs). ST2, on the other hard, doesn't need anything, is faster than running "find" would be to recursively list all files in the directory, and what's even more amazing is that neither the CPU usage nor the RAM usage shoots up while it's running.

I'm just curious as to whether anyone has any ideas about how ST2 does this under the hood.

like image 325
Amey Avatar asked Feb 22 '13 13:02

Amey


People also ask

How do I navigate in Sublime Text?

The Goto Anything shortcuts navigate the current file. If you have a project open, you can press Ctrl ⇧ R to launch Goto Anything In Project. This command will search for symbols across every file in your project.

How do I get folder view in Sublime Text?

You have to add a folder to the Sublime Text window in order to navigate via the sidebar. Go to File -> Open Folder... and select the highest directory you want to be able to navigate. Also, 'View -> Sidebar -> Show Sidebar' if it still doesn't show.

How do I use folders in Sublime Text?

Project files use the . sublime-project extension. You can add and remove folders to a project with the Project menu and the side bar's context menu. Futhermore, you can drag folders onto a window and they will be added automatically.

How do I open sublime project Explorer?

Then on sublime text go to view>sidebar>show sidebar. Finally, 3 tabs away from view is a project tab.


1 Answers

I believe Sublime Text 2 performs file scan on background when you open a folder / project. It's quiet about doing this. Various plug-ins do their own scans which are not that fast (like ctags). Internals regarding how ST2 does this are not documented or open.

Also it is not that fast, some people have issues with this: http://sublimetext.userecho.com/topic/49572-cache-folder-treegoto-anything-for-remote-volumes/

http://sublimetext.userecho.com/topic/49572-cache-folder-treegoto-anything-for-remote-volumes/

like image 58
Mikko Ohtamaa Avatar answered Nov 15 '22 11:11

Mikko Ohtamaa