TextExpander: Clipboard Underlining31 Oct 2015
A while back I refreshed and expanded upon my TextExpander snippet groups and promised to start covering some of the inner workings of what the snippets actually do. Today I found a bit of time to make a start on that and I’m beginning with some of the snippets related to underlining.
I write in text files quite frequently and find myself wanting to underline text. I think it’s a habit that I developed when writing documentation via a green screen mainframe terminal - anything that helps to give plain text some sense of formatting can really help. I guess that’s partly the essence of markdown these days; which I also use frequently.
The core of the snippets is a function called Underline. The function takes a single parameter of a text string that is to be used as the underline. I personally only pass in a single character, but you could pass more than one to have say alternating characters. I haven’t included any snippets that do this (I always just use a single character), but you could write your own snippet to do this and the Underline function will handle it.
The Underline function is relatively straight forward. It begins by grabbing a copy of the clipboard content. It the checks how long it is and uses that to generate a copy of the underline string guaranteed to be long enough to underline the text (unless the parameter had zero length of course - which is no underline). The clipboard content, a new line and the underline trimmed to the correct length are then returned and output.
|Label||* Library - Underline (JS)|
|Description||Helper function for clipboard text underlining|
The Underline function snippet along with a number of underlining and othe snippets are available in the Thought Asylum - Text Snippets Group. Currently the underlining snippets included in the group are for underscore (_), hyphen (-), period (.), asterisk (*), hash (#), plus (+), equals (=), tilde(~) and there’s a bonus snippet that uses a TextExpander fill-in to allow you to enter any string you like (its set to be one character wide but you can type more if you wanted to).
I hope that you find those snippets useful and have some level of understanding about how they work. If you have any suggestions you would like me to consider for future snippets, please feel free to ping a suggestion to me over on Twitter or just follow me for updates on TextExpander snippet updates, posts and all manner of useful stuff.