794jba
Last Updated: February 25, 2016
·
529
· minoroffense

Drupal and TextMate

For those who do Drupal development and use TextMate are probably aware there's a Drupal plugin for TextMate. What you may not know are some of the keyboard shortcuts that have been added.

Completion for hooks (Alt + H)

List available auto-complete hooks

List docs for current function

Put your cursor on a function name and press Ctrl-H (choose 1 for PHP, 2 for Drupal)

Coder format (i.e. automatic coding standard formatting)

Press Alt+Shift+Cmd+C (this may require two hands or flexible fingers) to have TextMate automatically repair any Drupal coding standard violations. This is no excuse not to learn the coding standard though!

Custom snippets

Last but not least, I like creating auto-complete scripts for populating the top of a new .module file or a .info file.

Edit the Drupal bundle (Bundles->Bundle Editor->PHP Drupal) and select New snippet.

My activation trigger is set to Tag Trigger and the keyword is "filehead" for files and "infohead" for the .info

The contents are pretty simple

<?php

/**
 * @file
 * Describe the file
 *
 * @author Mathew Winstone <mwinstone@coldfrontlabs.ca>
 */

and

; Description
;
; @author Mathew Winstone <mwinstone@coldfrontlabs.ca>

name = 
description = 
core = 
version = 

Of course I'll have to update these for D8, but that's another post.