Roping in TextWrangler

Lego cowboy with a lassoo

As Hook 42's Community Evangelist, I frequently venture into the prairie of Drupal documentation. It's not quite the Wild Wild West, but having a solid text editor in my holster keeps me saddled up and ready to ride.

Since I don't venture too far off the ranch into programming, I don't really have the need for a heavy IDE (Integrated Development Environment). I just need a tool that works on my Mac, writes with no fancy characters, and has the ability to do some basic formatting. TextWrangler definitely keeps me from squatting on my spurs, and the best part - it's free!

Building the Corral - Text Wrapping

According to Drupal Documentation for READMEs, text should manually word-wrap at 80 characters.

Navigate to Edit > Text options and select Soft Wrap Text. The following options are available for text wrapping:

  • to page width,
  • to window width, and
  • to character width.

When writing READMEs, I have my soft wrap set to window width, but have my page guide set at 80 characters, so I can manually add line breaks where I need them.

TextWrangler Soft Wrap window
 

 

Digging in the Spurs - Multiple Clipboards

Copy and pasting is a copywriter's trusty horse. TextWrangler allows for 6 clipboards!

Selecting Command-Shift-V will replace the current clipboard with the previous one. If you repeat the command, the clipboards will cycle backward through the history.

Booting the Bull - Search and Replace

Most text editors come equipped with search and replace, but the scale of TextWrangler's outshines all others. TextWrangler will comb through multiple files at once. This ability comes in handy when writing/editing Drupal modules whose names have changed, the name of the module has changed, and this change needs to be reflected in every instance in every one of the module files.

To do a simple search and replace navigate to Search > Find (Command + F). To search and replace through multiple file navigate to Search > Multi-File Search (Command + Shift + F).

TextWrangler File Search window

 

Cowboy Up! - Text Transformations

TextWrangler is pretty powerful for a plain text editor. It can wield more power than a bucking bronco. I don't harness all the power it has to offer as a copywriter or while writing Drupal documentation, but here is a short list of text transformation commands I frequently use.

Auto-expand tabs

Tabs are the nemesis for most programming languages, and that includes documentation standards for Drupal. TextWrangler has the option to replace the tab character with a pre-set number of spaces.

To change tab settings navigate to Text > Entab and choose your preferred tab width, and the tab will be replaced with spaces rather than a tab character. Subsequently, there is also the option to delete a tab's worth of spaces when Delete is pressed.

Change Case

Every good text editor provides the functionality to change case and TextWrangler is no different. Text can be changed by highlighting small areas, or all of the page’s text can be changed at once.

To change text case, navigate to Text > Change Case. There are five options:

  • All Upper Case,
  • All Lower Case,
  • Capitalize Words,
  • Capitalize sentences, and
  • Capitalize Lines.

Zapping Gremlins

Collaborating can bridge the gap between strategy and execution. But what if one of the cowgirls is stuck in the 1990s and insists on using Word, or the file someone shared is a PDF, so there are non-web readable characters and maybe some mysterious spacing issues? Zapping these little rascals is a snap with TextWrangler.

To zap Gremlins, navigate to Text > Zap Gremlins. TextWrangler can search for:

  • Non-ASCII characters,
  • Control Characters, and
  • Null (ASCII 0) characters.

After selecting which characters to search, you have the choice to:

  • Delete,
  • Replace with code,
  • Replace with characters, or
  • Replace with HTML entities.

TextWrangler Zap Gremlins window

 

Show Invisibles

Speaking of Gremlins, how do you see these pesky characters?

To see invisible characters such as line breaks, tabs, and other invisible characters, navigate to View > Text Display and select Show Invisibles.

After this option is in enabled you now have the option to see any spaces within the document as well, navigate to View > Text Display and enable Show Spaces.

Stripping Quotes

Smart or curly quotes are quite stylish, but not all browsers and web services recognize them, so it's better to not include them while writing Drupal documentation.

To strip Internet-style quotes, navigate to Text > Strip Quotes. This will remove quotes from selected text or from the current line if no text is highlighted.

Measuring the Rein - Balance While Typing

Although I don't write much code, every once in a while I am asked to review modules. There is nothing like one missing bracket or curly brace to ruin an afternoon. The Balance While Typing option will flash an open brace, bracket, parenthesis, or curled quote when you type the closing one. This will ensure that all delimiters are balanced.

To enable this option, navigate to Preferences > Editor Defaults and select the Balance While Typing option.

Lassoing the Beast - Normalize Options

The Normalize Options setting comes in handy when you are working on projects with inconsistent formatting. Normalizing resets the display and editing options for the chosen document to the defaults you set in Preferences.

! Warning: once this action has been performed, it cannot be undone !

To reset the editing and display options to your default settings, navigate to Edit > Normalize options and select Normalize.

Additional Helpful Wranglin'

  • Undo and Redo are unlimited
  • Check Spelling as You Type
  • Translate Line Breaks
  • Make Backup Before Saving
  • Show Line Numbers
  • Soft-wrapped line indentation
  • Hard-Wrapping Soft-Wrapped Text
  • Reopen Documents that Were Open at Last Quit