Book Image

TextMate How-To

By : Christopher J Mears
Book Image

TextMate How-To

By: Christopher J Mears

Overview of this book

Not all text editors are created equal. TextMate was created with versatility and power to the developer. Whether you want to organize your files in projects, utilize the efficiency of code completion, take advantage of the thousands of publicly available bundles, or gain insight using powerful regular expression searching, TextMate is an essential and easy-to-use tool you need in your development arsenal. "TextMate How-To" is a practical guide filled with conventional recipes on using one of the most popular text editors on the OS X platform. It is a great resource for anyone who wants to learn how to code more efficiently and effectively, no matter what programming or scripting language you use. This book will guide the reader through using TextMate for practical purposes. It will start with configuring the application, then cover navigation and editing of files, and finish with bundles and advanced features. Throughout the book, the reader will quickly master the key features of the application through easy to follow tasks. Using this book, the reader will learn the most common text editing and coding tasks including navigation through the document and searching of text. The reader will then learn about working with and navigating between files and projects as well as utilizing bundles to greatly speed up development. Finally, explore the ability to use shell commands and macros to increase productivity. With just a few hours, "TextMate How-To" will teach the reader everything necessary to hit the ground running with this powerful text editor.
Table of Contents (7 chapters)

Moving and aligning text (Should know)


This task will show you how to move text around, whether you want to move a selection of text up, down, or align it.

How to do it...

The different options used to move and align text are as follows:

  • Moving a selection up a line will insert the selected text into the previous line. From the menu, select Text | Move Selection | Line Up (Command + Control + up arrow).

  • Moving a selection down a line will insert the selected text into the next line. From the menu, select Text | Move Selection | Line Down (Command + Control + down arrow).

  • Left aligning will align text to the left. From the menu, select Text | Align | Left.

  • Right aligning will align text to the right margin based on the Wrap Column setting. From the menu, select Text | Align | Right.

  • Center aligning will center text using the Wrap Column setting as a guide. From the menu, select Text | Align | Center.

  • Justifying will space out the text evenly using the Wrap Column setting as a guide. From the menu, select Text | Align | Justify.

How it works...

Moving selections: When you are moving a selection of text, it is just as if you are dragging the text around with your mouse cursor (see Moving text with the mouse/track pad in the There's more… section). Don't be afraid. As you'll see in the following screenshot, it will not overwrite the line you are moving your selection to:

Aligning text: An important thing to note is that the alignment is based on the Wrap Column size (select View | Wrap Column).

There's more...

Since TextMate is a full-featured GUI text editor, you may also move text with the mouse or track pad. Plus, we'll look at a tip for moving entire lines up or down.

Moving text with the mouse/track pad

You can also move the text around by clicking and dragging a selection with your mouse or track pad, just like most other word processors. However, keeping your hands on the keyboard is faster and reduces repetitive strain (that is, carpal tunnel syndrome), and is typically preferred by hardcore coders.

Tip for moving entire lines of text

You can also move the entire line with the cursor, not by making a selection, but rather by invoking Line Up (Command + Control + up arrow) or Line Down (Command + Control + down arrow). However, notice that your cursor will stay positioned on the previous line. Therefore, you may prefer to select the line (Command + Shift + L) and then move it around as you please.