Book Image

TextMate How-To

By : Chris Mears, Christopher J Mears
Book Image

TextMate How-To

By: Chris Mears, 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)

Manipulating multiple lines and columns of text (Should know)

This is a more advanced task that will show how to select and edit multiple lines and columns of text.

Getting ready

Since this task is most useful with a list or multiple columns of text, you'll want to start out with something like the following:

How to do it...

The steps to manipulate multiple lines and multiple columns of text are as follows:

  1. Make a selection, ending the selection after the final character of the last row, as shown in the following screenshot:

  2. Switch to Column Selection by pressing the Option key, or from the menu, select Edit | Change to Column Selection:

  3. Edit the selection by holding down the Shift key and moving with the arrow keys. In this case, hold Shift and tap the right arrow key once to complete the full column selection:

  4. While the column is selected, you can move it by selecting Text | Move Selection | Column Left (Command + Control + left arrow) or by selecting Text | Move Selection | Column Right (Command + Control + right arrow).

  5. To edit all of the lines in a selection, make your selection, and from the menu, select Text | Edit Each Line in Selection (Command + Option + A). Once this is done, start typing and each line will be changed:

How it works...

Though the column manipulation is mainly used for data organization, the Edit all lines in a selection option has some very practical use cases for editing code. For example, if you have a list of items in HTML but don't want to copy and paste list item tags (that is, <li>) for each line, you can use the following set of keystrokes to quickly surround all of the items in <li> tags.

Select all of the lines, press Command + Option + A, and start typing the opening tag (<li>), followed by Command + right arrow (to move to the end of the line), and type the closing tag (</li>):