macOS KeyBindings for SearchLink

[Tweet]

SearchLink is one of the tools I’ve created that I use almost every day, so I’ve added a few bindings for it to my KeyBindings project. These will insert the basic syntax for SearchLink input, and you can add custom bindings for custom searches.

For details on adding these to your system, see the KeyBindings project as well as my original blog post on this project.

Once these are installed, you can use them in any Cocoa application. They’re all bound to ⌃⌘g (control-command-g), with the various search types bound to the next letter. So hitting ⌃⌘g and then typing g will wrap the selected text as [selected text](!g) for a Google search with SearchLink. Included bindings are:

SearchLink commands (⌃⌘g)
⌃⌘g g SearchLink Syntax: Google ([text](!g))
⌃⌘g ⇧a SearchLink Syntax: Amazon ([text](!a))
Apple (a)
⌃⌘g a i SearchLink Syntax: iOS App ([text](!itu))
⌃⌘g a m SearchLink Syntax: Mac App Store ([text](!mas))
⌃⌘g s SearchLink Syntax: Software ([text](!s))
⌃⌘g t SearchLink Syntax: Twitter User ([text](!@t))

Here’s the code. You can also find this in context on GitHub:

"^@g" = { // SearchLink commands
  // SearchLink Syntax: Google
  "g" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!g)", moveRight:, deleteBackward:, moveLeft:);
  // SearchLink Syntax: Amazon
  "A" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!a)", moveRight:, deleteBackward:, moveLeft:);
  "a" = { // Apple
    // SearchLink Syntax: iOS App
    "i" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!itu)", moveRight:, deleteBackward:, moveLeft:);
    // SearchLink Syntax: Mac App Store
    "m" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!mas)", moveRight:, deleteBackward:, moveLeft:);
    // SearchLink Syntax: Apple Music
    // "m" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!g)", moveRight:, deleteBackward:, moveLeft:);
  };
  // SearchLink Syntax: Software
  "s" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!s)", moveRight:, deleteBackward:, moveLeft:);
  // SearchLink Syntax: Twitter User
  "t" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!@t)", moveRight:, deleteBackward:, moveLeft:);
};

As an example there are a couple I use for my own blog searches. It should be pretty obvious how to modify these…

SearchLink custom searches
⌃⌘g b SearchLink Syntax: BrettTerpstra.com ([text](!bt))
⌃⌘g p SearchLink Syntax: BrettTerpstra.com Projects ([text](!btp))
⌃⌘g m SearchLink Syntax: IMDB ([text](!imdb))

And here’s the code for that (include this within the ^⌘g section from above):

  // SearchLink Syntax: BrettTerpstra.com
  "b" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!bt)", moveRight:, deleteBackward:, moveLeft:);
  // SearchLink Syntax: BrettTerpstra.com Projects
  "p" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!btp)", moveRight:, deleteBackward:, moveLeft:);
  // SearchLink Syntax: IMDB
  "m" = (setMark:, moveRight:, insertText:, " ", deleteToMark:, insertText:, " [", moveLeft:, deleteBackward:, moveRight:, yank:, moveLeft:, insertText:, "](!imdb)", moveRight:, deleteBackward:, moveLeft:);

Read more about how to use these and see the full set on the KeyBindings project page. And seriously, if you haven’t dug into SearchLink yet