TextMate Manual Table of Contents 1 Preface 1.1 About the Documentation 1.2 Philosophy of TextMate 1.3 Terminology 1.4 Limitations 2 Working With Multiple Files 2.1 Creating Projects (With Tabs) 2.1.1 Auto-Updating Projects 2.1.2 Filtering Unwanted Files 2.1.3 Text and Binary Files 2.1.4 Positioning the Project Drawer 2.2 Find and Replace in Projects 2.3 Moving Between Files (With Grace) 3 Navigation / Overview 3.1 Bookmarks 3.2 Collapsing Text Blocks (Foldings) 3.2.1 Customizing Foldings 3.3 Function Pop-up 3.3.1 Customizing the List 4 Working With Text 4.1 Auto-Paired Characters (Quotes etc.) 4.2 Completion 4.3 Copy and Paste 4.3.1 Clipboard History 4.3.2 Re-indented Paste 4.4 Editing Modes 4.4.1 Freehanded Editing 4.4.2 Overwrite Mode 4.5 Find and Replace 4.5.1 Inserting Newlines and Tabs in the Find Dialog 4.5.2 Find Clipboard 4.6 Moving Text 4.6.1 Increase/Decrease Indent Level 4.6.2 Move Text Up/Down/Left/Right 4.6.3 Re-indent Text 4.7 Selecting Text 4.7.1 Editing Multiple Lines 4.7.2 Column Selections 4.8 Column Movement / Typing 4.9 Smart Tab Behavior 4.10 Spell Checking 4.11 Using Spaces Instead of Tabs 1 Preface 1.1 About the Documentation The intended purpose of the documentation is to explain the main features of TextMate and to highlight features that may not be obvious to first time users. The documentation is not exhaustive. You should have a good understanding of what a text editor is, in particular you should have some experience with Cocoa's text edit control (used in TextEdit, Mail and Xcode). While TextMate does not use that control, it does mimic its behavior for the most part. If you want to print this documentation then here is a printable version. 4 Working With Text TextMate tries for the most part to mimic the behavior of the NSTextView system component, as used by applications such as Mail, Safari and basically all other Cocoa applications. Some of the extra features related to text editing are covered in this section. 4.1 Auto-Paired Characters (Quotes etc.) When writing structured text (like markup or source code) there are characters which go together in pairs. For example in a programming language you rarely type an opening brace ({) without also needing the closing brace (}). To help you keep these characters balanced, TextMate will insert the appropriate closing character after the caret when you type the opening one. If you type the closing character TextMate is smart enough to overwrite the auto-inserted one. If you type an opening character and then delete it using backward delete (⌫) then the auto-inserted character will also be deleted. If you only want to delete the auto-inserted character, use forward delete instead (⌦). It is also possible to wrap a selection in an open/close character by selecting text and typing the opening character. For example if you type foo, select it and type ( then TextMate will make it (foo) placing the caret after the ending parentheses. The actual character pairs are defined in the bundle preferences with different settings for different languages and contexts. For example, in source code an apostrophe is set up to have itself as a closing character, except for comments and strings. This is achieved using scope selectors. Two useful shortcuts in relation to auto-paired characters (defined as macros in the Source bundle and overridden for a few languages) are: ⌘↩ Move to the end of the line and insert a newline. For example if you write: print("foo Then you will have ") to the right of the caret and can now use ⌘↩ to skip these two characters and insert a new line. ⇧⌘↩ Move to the end of the line, insert a ; and then insert a newline. 4.6 Moving Text 4.6.1 Increase/Decrease Indent Level In the Text menu there is a Shift Left and Shift Right action bound to ⌘[ and ⌘]. These will increase and decrease the indent by the size of one tab. On many european key layouts these keys are rather awkward, so in addition to these, you can also use ⌥⇥ and ⌥⇤ (where ⇤ is achieved using ⇧⇥). 4.6.2 Move Text Up/Down/Left/Right If you want to move a line/block up/down a few lines or move a word/column selection, it can be done by holding down ⌃⌘ and using the arrow keys to move the selection around. It also works for moving lines up/down without a selection. 4.6.3 Re-indent Text If you have code which has broken indent, you can select it and use Text → Indent Selection (without a selection it indents the current line). The rules for estimating the indent are setup per-language using bundle preferences. For more details see the indentation rules section. 4.7 Selecting Text Selecting text is achieved by holding down ⇧ while using the normal movement keys. In addition the Edit → Select submenu has actions to select current word, line, paragraph, enclosing brackets and entire document. 4.7.1 Editing Multiple Lines Sometimes there is a need for adding a suffix to lines of variable length, or maybe editing the last part of these lines. Although you can use find and replace for this, an easier way is to select the lines that needs to be edited, then use Text → Edit Each Line in Selection (⌥⌘A) and the caret will be placed at the end of the first line in the selection. You can now type new text, delete text or go back and edit existing text and this will be mirrored down through all the (previously selected) lines. To leave this mode, simply move the caret away from the current line. 4.7.2 Column Selections It is possible to select column data either by holding down ⌥ and making the selection with the mouse, or making a regular selection and then pressing ⌥ once (which toggles between the two types of selection). You can use all the normal actions on a column selection e.g. move selection, replace in selection, transpose (lines), actions from the Text menu, filter the selection through a shell command, etc. 4.8 Column Movement / Typing Using arrow up/down with ⌥ will move the caret to the first/last row in the current column. Hold down ⇧ to get it selected. Column Data For example if you have column data as shown above with the caret in front of foo, press ⌥⇧↓ and it will move the caret down in front of fud and leave the text between foo and fud selected. Column Movement You may now either want to press ⌥ once to switch to a zero-width column selection, then start typing to type on each line. Column Typing Alternatively use ⌥⇧→ and then ⌥ to leave the entire column selected (in column mode). Column Selection 4.9 Smart Tab Behavior When using the tab key at the beginning of a line, TextMate will insert as many tabs as it estimates to be correct for that line. If the line already has text the caret will move to the front of this text. If the line already has the correct indent (or above) a single tab will be inserted. 4.10 Spell Checking TextMate supports the system wide 'Check Spelling as You Type'. This can be changed in the Edit → Spelling submenu. You can bring up the context sensitive menu for a misspelled word to get spelling suggestions. Since TextMate is intended for structured text it is possible to exclude parts of the document from being checked. This is done by creating a preferences item in the bundle editor, setting spellChecking to 0 and filling in the scope selector with the selector to target for no spell checking. By default spell checking is disabled for source code except strings and comments and also for keywords, tags and similar in HTML, LaTeX, Markdown, etc.