This task will cover creating and saving projects through various methods, including opening directories, drag-and-drop, and by using the command line.
If you would like to use the drag-and-drop to dock method, you will need to copy the TextMate application to the dock.
If you would like to use the command-line method, you will need to install the mate
command-line executable, which you are prompted to do during the first run of TextMate. You may also install it from the File menu (select Help | Terminal Usage…) at any time. See the Configuring TextMate section explained earlier in the chapter, for more information.
Let's cover the typical ways to create projects in TextMate:
Create a new project through the menu (select File | New Project) or with the keyboard shortcut (Command + Control + N). You can then add files to it by dragging and dropping from the Finder or by adding existing files from the Project Drawer toolbar, as shown in the following screenshot:
Opening a folder or multiple files will also create a project. You can do this from the menu by selecting File | Open (Command + O).
Dragging and dropping a folder or multiple files to a TextMate dock item will open those files into a new project. This is shown in the following screenshot:
Command line is also available if you're comfortable in the Terminal. You can create new projects via the
mate
shell command. Some examples are as follows:mate howto.txt notes.txt # Open multiple files mate textmate-howto/ # Open a folder mate . # Open current directory
Projects allow you to quickly work with multiple files. Once created, you can quickly search for and open files (see the Traversing Files section), create new files, organize files into groups, create project-specific shell variables, and more.
Once you open a project, you can easily save it by selecting File | Save Project (Command + Control + S) or by selecting File | Save Project As… (Command + Control + Shift + S). The latter will allow you to rename a previously saved project.
Let's cover how to exclude files or folders from your projects, as well as why you may want to do so.
Sometimes excluding files will speed up search time, for example, if your project includes long logfiles with the extension .log
. Unfortunately, the process to exclude files requires knowledge of regular expressions, which is a bit out of the scope of this book.
However, you can find where to exclude files by going to File | Preferences (Command + ,), navigating to the Advanced tab, and selecting the Folder References section. There you will edit the File Pattern and Folder Pattern fields:

Taking the example I gave previously regarding excluding any files with the extension .log
, the File Pattern field would look as follows:
!(/\.(?!htaccess)[^/]*|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp|\.log)$
Note the |\.log
at the end. If you aren't familiar with regular expressions, note that this says to exclude files that end in .log
(along with excluding .htaccess
, files ending in .tmproj
, .o
, .pyc
, and so on).