How to type [[]] (create links) quickly for wikis in Mac OS X

Here goes another one of my unexpected posts… a technology tutorial post? ^^;

I think TiddlyWiki is a very simple and powerful tool to create personal wikis without the fuss of set-up (cool navigation system that doesn’t force you to jump to new page as well).

While it’s fine to use wikis that are already out there, that many people have contributed information to, those wikis often contain too much information, information I don’t need or care, spoilers and ads (well, that’s how the ones hosting the wikis get ‘compensated’, while naive passionate contributors essentially ‘work for free’, but enough of the negative view ^^;).

I think it’s just more fun to build my personal ‘network of knowledge’ as I’m playing game or learning new subject.

One can store TiddlyWiki as a single HTML file in local storage, or even use TiddlySpot service to host it and make changes online (instructions on how to do it here)

Anyway, there’s one drawback that makes inputting entries in wikis less fun: to add a link, one would need to type [[]]. That’s 4 keystrokes, maybe 6 considering one might need to move the cursor backward 2 times (third world problems, I know ^^;).

(I know there’s a CamelCase convention for links for some types of wiki, but some languages such as Japanese don’t benefit from it ^^;)

So I found a way on how type [[]] quickly on Mac OS X (I’m using Yosemite Developer Preview, should also apply to older versions) and even automatically move the cursor to the right spot by creating a custom keyboard shortcut.

(Although we can use Text Substitution feature in Mac OS X, not all applications support it, and Google Chrome unfortunately seems to be one of them (I have issues with saving TiddlyWiki in Safari). And as far as I know, there is no way to move the cursor to the right place with Text Substitution)

Here’s how:

1. Open Automator (under Other in LaunchPad)

2. Click File -> New if step 3 below doesn’t appear

3. In ‘Choose a type for new document:’, pick Service

4. Change ‘Service received selected’ to ‘no input’. Keep ‘any application’

5. On the left, pick Utilities and double-click ‘Run AppleScript’

6. Replace ‘(* Your script goes here *)’ part with the script below (i.e., not the entire thing):

tell application "System Events" to get name of process 1 whose frontmost is true
tell application result to activate
tell application "System Events" to keystroke "[[]]"
tell application "System Events" to keystroke (ASCII character 28)
tell application "System Events" to keystroke (ASCII character 28)

7. Click File -> Save. I personally named it [[]]

8. Go to System Preferences -> Keyboard -> Shortcuts

9. Pick Services, find the Service we just created ([[]] if you follow my personal naming, and it should be under General. If it’s under Text, you might miss step 4. If you made mistakes, see step 2 below)

10. Click ‘add shortcut’ and pick a keyboard shortcut that doesn’t conflict with existing shortcuts (I personally used Control + Command + [ )

And that’s it! Try using the shortcut on any text field. If it doesn’t work, chances are the shortcuts are already taken, either system-wide or application specific.

How to clean up the mess we did, in case you don’t like it:

1. Go to Automator, File -> Open, right click the Service file we just created and move to Trash.

2. You might need to close and reopen System Preferences to see the changes you made in Automator in Keyboard Shortcuts

So yeah, I hope you have more fun from now on in editing and creating wikis ^^


The above tutorial is for inputting [[]] quickly with cursor set in the right place. Here’s how to wrap already-typed text with [[]] when you want to turn the text into a link (e.g., from SomeLink to [[SomeLink]])

1. In Automator, create a new Service

2. This time set ‘Service receives selected’ as text and tick ‘Output replaces selected text’. Keep ‘any application’

3. On the left, pick Utilities, double-click ‘Run AppleScript’ and replaces the return line with this:

return "[[" & input & "]]" as string

4. Save (I personally save it as ‘Wrap with [[]]’)

5. This action is then available by selecting a text and then right-clicking it. You can also create a keyboard shortcut (can’t be the same as the action made in previous tutorial though). This time it’s under Text section since it takes text as input.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s