Want to use TextMate for development? Then here are the basics you are going to need to know to get started. This isn’t an exhaustive list of everything in the world to be known about TextMate, its just a list of things to help you get started or maybe teach you something you didn’t already know.

Using the Terminal

You are going to want to enable Shell support for TextMate. This way you can use the mate command inside the Terminal and open your source code directories directly into TextMate.

  1. Open TextMate Preferences by typing: ⌘ + ,
  2. Choose Terminal
  3. Click Install

Now you should be able to use the mate command inside your directory!

Running Code

You can use TextMate to try out a snippet of code.

  1. Create a new file in TextMate by typing: ⌘ + N
  2. Save the file by typing: ⌘ + S
  3. For this example, let’s use a Ruby file. Name the file: test.rb
  4. Now add the following code to the file:

puts 'hello from TextMate!'

Save the file and Run it by typing: ⌘ + R

You should see a window open with the results of running your code! If this didn’t work for you - you might not have the ruby command in your PATH variable. Installing Ruby is beyond the scope of this guide.

Keyboard Shortcuts

You need to get familiar with these shortcuts when working in TextMate:

Manipulating Text

Indent ⌘ + ] Inserts an indent
De-indent ⌘ + [ Removes an indent
Append Line ⌘ + ENTER New line after current line
Insert Line ⌘ + ⌥ + ENTER New line before current line
Delete Line CTRL + SHIFT + K Delete current line
Duplicate Line CTRL + SHIFT + D Duplicate current line
Join Lines CTRL + SHIFT + J Join “current” and next line
Move Line CTRL + ⌘ + up/down Move current line up or down
Toggle Quotes CTRL + SHIFT + “ Switch between “ and ‘
Toggle Case CTRL + SHIFT + _ Toggles: camel, snake, nerd case

Selecting Text

Select Line SHIFT + ⌘ + L Select your current line
Select Line from Cursor SHIFT + ⌘ + → Right hand side
Select Line from Cursor SHIFT + ⌘ + ← Left hand side
Select Word CTRL + W Type, Repeat: Selects next instance of word
Select Word from Cursor SHIFT + ⌥ + → Type, Repeat: Right hand side
Select Word from Cursor SHIFT + ⌥ + ← Type, Repeat: Left hand side
Select Column ⌥ + Mouse Drag Select text vertically
Choose File ⌘ + T Find a file in the project
Choose Method SHIFT + ⌘ + T Finds a symbol in the file

Search and Finding

Search File ⌘ + F Search and Replace current file
Search Project SHIFT + ⌘ + F Search and Replace root folder
Incremental Search CTRL + S Search while typing
Go to Line ⌘ + L Place cursor on a line number
Go to Next Selection ⌘ + G Find each instance of selection
Show Invisibles ⌘ + ⌥ + I Works on Files or File Browser

Customizing

You are going to need to know about tm_properites dotfiles. TextMate looks for these files in your project directory, all the way up to your home directory to customize your editing experience. Here’s the two most common customizations:

Set a Font Size Globally

  1. In your home directory, create a file named: .tm_properties
  2. Add the following to the file:

fontSize = 16

Anything you add to the tm_properties dotfile in your home directory will be applied globally to all projects you open with TextMate.

Exclude Directories

When using the awesome ⌘ + T keyboard shortcut, you will probably want to prevent folders such as logs from showing up in the search results.

  1. In your project directory, create a file named: .tm_properties
  2. Add the following statement to the file:

excludeInFileChooser = "{$excludeInFileChooser,logs}"

These folders will still show up in the File Browser, if you don’t want to see them in there either, then simply change the statement to:


exclude = "{$exclude,logs}"

Remember you can always toggle visibility of the files that are hidden in the File Browser by using the Show Invisibles keyboard shortcut: ⌘ + ⌥ + I.

The tm_properties file has a ton of customization options available. You can read about them in the Filtering Files section of the Official Documentation

Themes

Your theme choice is probably as personal as your editor choice. Luckily with TextMate you have a lot of options.

TextMate themes are saved with the extension tmTheme. Installing them is as simple as double-clicking them. First you will need some themes to choose from:

Github (filmgirl) TextMate Themes

Simply clone this repo to get all these themes, then browse the screenshots here.

Dracula - a dark theme for TextMate

Follow the directions on the Dracula site to get this great theme.

Installing Themes

  1. Double-click the theme file
  2. In the TextMate dialog that pops up choose Themes from the bundle selector
  3. From the View menu in TextMate, choose Theme and select your Theme by name

That’s it! Do you have a theme you would like me to highlight on this guide. Let me know in the comments.

I hope you enjoyed this guide. You are now ready to build the next big thing using TextMate 2!