Text Expander Snippets

Text Expander Snippets

What is text expansion?

I’m anxiously awaiting the day when computers will be controlled sans keyboard. With the newer releases of OS X, Siri helps to reduce the number of key strokes I make during a given day. Yet, Siri’s smarts only take us so far towards retiring the keyboard. The next best tool I’ve integrated into my daily workflow is TextExpander.

Why use it?

TextExpander allows you to type short abbreviations, called snippets, that auto-expand into full words, phrases, or even boilerplate emails. You can make the simplest of abbreviations leap into longer-text phrases, or get fancy with dropdown options, optional text blocks, dynamic dates and times, or even carry out complex functions via javascript. TextExpander is a powerful application, with many, many varied use cases.

The goods.

Below, I’ve included a few of my favorite snippets grouped according by category. Each snippet begins with a brief description, followed by the expansion abbreviation set equal to the expansion code.



DEVELOPMENT

I often have trouble remembering the commands for each development tool I’m currently using. I’ve established my own TextExpander snippets to unify my development experience.

Serve Jekyll/Middleman/Rails and Automatically Open Browser Window:

xjekyll s = open http://127.0.0.1:4000/ %key:enter% jekyll serve %key:enter%

xmiddleman s = open http://0.0.0.0:4567/ %key:enter% middleman serve %key:enter%

xrails s = open http://0.0.0.0:3000/ %key:enter% rails s %key:enter%

CSS Transitions:

xcsstrans = -webkit-transition:%fill:type% %fill:seconds%s ease-in-out;-moz-transition:%fill:type% %fill:seconds%s ease-in-out;-o-transition:%fill:type% %fill:seconds%s ease-in-out;transition:%fill:type% %fill:seconds%s ease-in-out;



TERMINAL

As a developer, I spend half my day typing away into the black abyss of a terminal window. Honestly, I love the frictionless, minimal working environment terminal affords. With TextExpander, you can make the experience even smoother.

Shows Hidden Files:

xshow = defaults write com.apple.finder AppleShowAllFiles TRUE

Hides Hidden Files:

xhide = defaults write com.apple.finder AppleShowAllFiles FALSE

Changing the Format Of Screen Shots:

xsreenshot = defaults write com.apple.screencapture type %fillpopup:name=image type:default=jpg:png:bmp:gif%

xcddeeply = cd ~/Documents/github_repositories/deeply/

xcdless = cd ~/.nylas/dev/packages/less-is-more/



GIT

How many times do you type the same git commands in a day? Perhaps you should be using snippets to smooth over your commit process.

Add all files for next commit:

xgita = git add –all .

Commit with message:

xgitc = git commit -m “%|”



MARKDOWN

Markdown is a brilliant and mostly dead-simple tool, and yet I can’t be the only person who forgets the syntax for links and images. Again, TextExpander to the rescue.

xmdl = [%fill:name%][%fill:reference%] %| [%fill:reference%]:%clipboard

Markdown Images:

xmdi = ![%|](%clipboard “%filltext:name=Optional Title:default=Image Caption%”)



DATES

I will never write out a date again on my Mac or iPhone thanks to these snippets.

Dynamic Date for Consistent Naming Convention:

xdate = %y%m%d

Dynamic Full Format Date:

xfulldate = %A, %B %e, %Y



FORMATTING TEXT

Thanks to TextExpander’s incorporation of javascript, you can even effortlessly format text strings. Here are a few snippets that I use regularly.

Paste Cliboard into Lowercase:

xcblow = // Output the clipboard contents in all lower case. TextExpander.pasteboardText.toLowerCase( );

Paste Cliboard into Sentence Case:

xcbsent = // Output the clipboard contents where every character is lower case except for the start of sentences which is upper case. String.prototype.toProperCase = function( ) { return this.replace(/((?:\S[^.\?!])[.\?!])/g, function(strInput){return strInput.charAt(0).toUpperCase( ) + strInput.substr(1).toLowerCase( );}); }; TextExpander.pasteboardText.toProperCase( );

Sort Cliboard Contents into Alphabetical Order:

xcbsortalpha = // Output the lines of text on the clipboard sorted in alphabetic order. TextExpander.pasteboardText.split(“\n”).sort( ).join(“\n”);

Paste Cliboard into Titlecase:

xctitle = // Output the clipboard contents where every character is lower except for the start of each word which is in upper case. String.prototype.toProperCase = function( ) { return this.replace(/([^\W_]+[^\s-]*) */g, function(strInput){return strInput.charAt(0).toUpperCase( ) + strInput.substr(1).toLowerCase( );}); }; TextExpander.pasteboardText.toProperCase( );

Paste Cliboard into Uppercase:

xcbup = // Output the clipboard contents in all upper case. TextExpander.pasteboardText.toUpperCase( );

Delete Duplicate Words in the Clipboard before Pasting:

xcbdeldup = Array.prototype.removeDuplicate = function(){ var result = []; for(var i =0; i < this.length ; i++){ if(result.indexOf(this[i]) == -1) result.push(this[i]); } return result; } var str = “%clipboard”; str = str.replace(/[ ]/g,””).split(“,”).removeDuplicate().join(“, “);



Hopefully, these snippets will prove useful for others. I’d love to hear about more use cases or improvements to the snippets above.

xoao = Over and out!

March 02, 2016

Back To Top