Multi-Folder Projects
April 15, 2015 maxbrunsfeld
We’ve recently added the ability to open multiple folders in the same Atom window. You might find this useful if you often edit files in several folders at the same time.
Using Multiple Folders
You can start Atom with multiple folders by specifying their paths as command-line arguments:
atom ./first/folder ./second/folder
You can also add a folder to an existing Atom window by running Application: Add Project Folder
from the Command Palette. The key-binding for this command is cmd-shift-o
on Mac and ctrl-alt-o
on Linux and Windows.
To remove a folder from the project, right-click on it in the tree-view and select Remove Project Folder
from the context menu. You can also add project folders by selecting Add Project Folder
in this menu.
All of Atom’s built-in packages now support multiple project folders. For example:
- If you use ctags, you can jump from a usage of a method in one project folder to its definition in another project folder using
Symbols View: Go To Declaration
. - The Find and Replace panel searches across all project folders by default. You can search a particular project folder by typing its name, or a path beginning with its name, into the
File/Directory pattern
field. - The Fuzzy Finder dialog searches files in all of your project folders. You can filter the results by project folder by including characters from a project folder’s name in your search string.
Updating Your Packages
If you maintain an Atom package that uses atom.project
, we encourage you to make sure that it handles multiple project paths gracefully. We have made some additions to the Project
API:
- If you have a file path and you need to know how it relates to the current project paths, you can use
atom.project.relativizePath(filePath)
, which returns both the path to the project directory that containsfilePath
and the relative path tofilePath
from that project directory. The fuzzy-finder package uses this method when abbreviating file paths. - To access the git repository for a given directory, use
atom.project.repositoryForDirectory(directory)
. Atom’s TextEditor class uses this method for theEditor: Checkout Head Revision
command.
Looking Ahead
Now that this functionality is in place, we’ll be taking further steps to refine the experience of working with multiple folders in Atom. We have an open issue to gather feedback on this feature. Please let us know if you have ideas about how we can improve it.