9 min read

Installing bundles with GetBundles (Must know)

Installing bundles can be a bit daunting if you’re not used to working in the Terminal. This task will cover finding and installing bundles with GetBundles, which is a bundle that allows you to install other publicly available bundles.

Getting ready

Installing GetBundles is much like installing bundles manually, which we will go over later in this task. It’s more complicated than installing themes and requires you to use the Terminal application. The steps to install are as follows:

  1. Open the Terminal application, which is located in your Applications folder under the Utilities folder.

  2. From the Terminal, enter the following commands:

    mkdir -p ~/Library/Application Support/TextMate/Bundles cd ~/Library/Application Support/TextMate/Bundles svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles. tmbundle/ osascript -e 'tell app "TextMate" to reload bundles'

  3. Now that you have GetBundles installed, you can open the GetBundles window via the menu by selecting Bundles | GetBundles | Get Bundles.

How to do it…

Once you open the GetBundles bundle, you can install any bundle by selecting one or more bundles and clicking the Install Bundles button:

How it works…

The GetBundles bundle has a simple interface that lists bundles and their descriptions with the search option, filters, and tools:

Some of the features of GetBundles are explained in the following section:

  • Filtering: This allows you to filter the bundles by Official, Under Review (as in under review by Macromates), 3rd Party, and All.

  • Searching: You can search for a bundle using two methods—literal or with a regular expression. The search will apply to the current filter you have selected. It will also search both the bundle name and the description.

  • Tools: The tools drop-down menu (that is, the gear icon in the bottom left-hand side of the window) will allow you to use options such as Reload Bundles List, Refresh Local Bundle List, Install all Updates for your currently installed bundles, view the log, and more. You can also see information about the bundle, show the currently installed bundles in Finder, and open the bundle source in Textmate with the icon tools located at the top of the GetBundles window. The tools drop-down menu options are shown in the following screenshot:

  • Installed bundles: All properly installed bundles have a status of Ok.

  • Sorting: All the columns in the bundle list are sortable. For example, if you want to sort by installed bundles, click on the Status column header until the arrow is pointed down, as shown in the following screenshot:

  • Uninstalling bundles: Removing bundles is as easy as selecting an installed bundle and clicking the Delete button, which is shown in the following screenshot:

There’s more…

If you’d like to install bundles manually, you can check out the source files directly from Macromate’s subversion repository.

Installing bundles via Github or SVN

If you’re comfortable using the Terminal, you can manually install bundles using subversion (SVN) or git (via Github):

  • Subversion (SVN): The official TextMate bundles can be found in an SVN repository hosted by Macromates at http://svn.textmate.org/trunk/.

  • Git: The official TextMate bundles are mirrored on Github at https://github.com/textmate/. TextMate bundles are typically listed in Github. Since it’s a common convention, search the site for repositories with tmbundle in the name.

Learning and loving bundles (Must know)

This task will quickly cover the use of bundles, including the beauty of tab completions and how to easily find the bundle item you’re looking for along with the tab completion abbreviation or the keyboard shortcut.

How to do it…

  • Tab completion: Type in a tab trigger, for example, div in an HTML document, and press the Tab key. The following screenshot shows how the code is auto-completed:

  • Opening bundle actions: You can open the bundle actions by clicking on the gear icon in the status menu or with the keyboard shortcut Control + Escape.

  • The Select Bundle Item window: This window allows you to quickly find a particular bundle action, whether it’s a tab-completed snippet or a keyboard shortcut. You can open the window from the menu by selecting Bundles | Select Bundle Item… or use the keyboard shortcut Command + Control + T. This window is shown in the following screenshot:

How it works…

  • Tab completion is one of many ways in which bundles can help with writing and code development. They are very useful shortcuts that will greatly speed up your coding.

  • Opening bundle actions is just like opening the bundles menu item, but with the benefit of easier access through a simple keyboard shortcut.

  • The Select Bundle Item window is used just like the Go to File… option with projects. You can type in the search bar to quickly filter all of the bundle actions.

There’s more…

If you want to dig deeper into learning more about a particular bundle, Bundle Editor is the place to go.

Exploring bundles

You can filter and view many other bundle items, such as commands and macros, in the Bundle Editor (select Bundles | Bundle Editor | Show Bundle Editor or Command + Option + Control + B). If you want to know how a particular bundle item works, find it here. The Bundle Editor window is shown in the following screenshot:

Making a TODO list (Should know)

This task will utilize the official TextMate TODO bundle to display a to-do list compiled directly from your project using common comment keywords such as TODO, FIXME, CHANGED, and RADAR.

How to do it…

  • Insert a TODO item by typing a TODO, FIXME, CHANGED, or RADAR keyword anywhere in the comments of your document. You may also use tab completion by typing todo and then pressing Tab, which will automatically create a new comment. The different types of comments are shown in the following screenshot:

  • You can view the TODO list for the current document through the menu by selecting Bundles | TODO | Show TODO List or via the keyboard shortcut Control + Shift + T. The list is shown in the following screenshot:

How it works…

As you may have surmised, the TODO bundle will search through your current document or project for the TODO, FixMe, changed, and RADAR keywords. Note that the keyword is not case sensitive and can be followed by a whitespace character, a comma, or a colon. This is shown in the following screenshot:

To search through multiple files or folders in your project, you need to select those files and/or folders in the Project Drawer menu. For example, to search the entire project select the toplevel folder and click on Show TODO List (Control + Shift + T).

There’s more…

You may customize the TODO bundle to suit your color and pattern preferences as well as add more markers. We’ll also cover the Tasks bundle, which will help you create well-formatted to-do lists.

Setting other preferences

You can choose what words count as TODO keywords. To do this, go to TODO Preferences via the File menu by selecting Bundles | TODO | Preferences. This window is shown in the following screenshot:

You may also change the color and regular expression pattern of the keywords, making this bundle quite versatile.

Tasks bundle

If you love to-do lists, a similar bundle called Tasks is also available for installation via GetBundles. The Tasks bundle allows you to easily create simple to-do items (Ins or fn + return on laptops to create a task) and mark them as complete (Command + D). An example of a to-do list is shown in the following screenshot:

More information on official TextMate bundles

The other official TextMate bundles are extremely helpful. However, this book will attempt to show you bundles and tools about which you might not already be aware. You can read about some highlights of the other bundles in the TextMate manual at http://manual.macromates.com/en/bundles.

Becoming a Zen Coding master (Should know)

Zen Coding is a method to code HTML at top speed through the use of CSS selectors and other abbreviations. This task will briefly cover the philosophy and use of the most common bundle items.

Getting ready

Install the Zen Coding bundle via GetBundles.

How to do it…

In order to expand a Zen Coding abbreviation or alias, you need to use the keyboard shortcut Command + E, or from the menu select Bundles | Zen Coding | Expand Abbreviation.

For example, div#main will expand to <div id=”main”></div>

Here are some more examples:

How it works…

On the Zen Coding website, at http://code.google.com/p/zen-coding/, Zen Coding is defined as an editor plugin for high-speed HTML, XML, and XSL (or any other structured code format) coding and editing. The core of this plugin is a powerful abbreviation engine, which allows you to expand expressions—similar to CSS selectors—into HTML code.

Zen Coding can greatly expedite HTML development. There are some other helpful actions included in this bundle:

  • The Increment/Decrement number by 1 action (Command + ?): Add or subtract 1 from the number to the left of the cursor. An example use case would be if you duplicate a line (Control + Shift + D) and then want to increase the ID by 1.

  • The Remove Tag action (Command + Shift + K): Remove the tag surrounding the text.

  • The Wrap with Abbreviation action (Command + Shift + A): Wrap current selection with the abbreviation you enter into the pop-up dialog after running this action.

There are more actions, so definitely explore all of them. A handy cheat sheet is available at http://code.google.com/p/zen-coding/wiki/CheatSheets.

There’s more…

The purpose of covering Zen Coding in this book is to highlight the power of TextMate as a full-featured coding tool. It will save you a lot of time if you do a lot of HTML and CSS coding.

More information about Zen Coding

To find out more information about Zen Coding, the philosophy, and more actions, you should visit the official website at http://code.google.com/p/zen-coding/. Listed at this website are a number of plugins available for other applications, should your friends and colleagues be jealous of your fast HTML coding abilities.

Zen CSS

Along the same lines as Zen Coding for HTML, there is also Zen Coding for CSS, which mostly utilizes short-form abbreviations for CSS properties.

Find out more by going to this wiki page at http://code.google.com/p/zen-coding/wiki/ZenCSSPropertiesEn.

Summary

The author of this article, Chris Mears, describes another way to find text, this time searching through your entire project. This task will also include some tips on how to speed up your search and even cover some caveats for larger projects.

Resources for Article :


Further resources on this subject:


LEAVE A REPLY

Please enter your comment!
Please enter your name here