Jump to content

Snippets and input cursor

Recommended Posts

Hi All,


Alfred newbie here.


I'm intrigued by snippets.  I hope I can accelerate greatly using them.


One thing that I couldn't see how to do, though: indicate where the cursor should land once pasted.


For example, let's say I make the snippet '§proc' to expand to:


function () {



I'd like the cursor to be just before the (), so that I can type the function name and move on from there.


I have to move the mouse and click before the (), or use the arrow keys to get me there.


It'd be great if there were a placeholder to indicate where the cursor should end up:


function {cursor}() {



...or some such.

I looked in the documentation, but I couldn't find the answer. Can anyone point me to where this is documented?



Link to post

@Ken Corey No problem - happy to help!


As you're a new user, I thought it'd be worth mentioning that every preference pane has a question mark icon (including many sub-preferences panes) leading to the relevant documentation for the feature, so don't hesitate to click through.


Screen Shot 2017-07-24 at 11.02.05.png


For example, for snippets, you'll find a general feature description, links to setup and troubleshooting, how to use dynamic placeholders etc.


In the case of Workflow objects, we've included numerous example workflows that can either be added from Alfred's built-in selection, or imported to play with and discover the features :)


Of course, when you can't find an answer, this forum's full of lovely people happy to help you out!



Link to post
  • 2 years later...

@chris Yup, looks like when I re-wrote the new Dynamic Placeholders page (now found here: https://www.alfredapp.com/help/workflows/advanced/placeholders/) I missed out the cursor. I've added it now.


It's a fairly self-explanatory one using {cursor}, and it's included in the placeholders list in-app (the square brackets bottom left of the Snippets content window includes examples of the various dynamic placeholders) but it's back in the docs now for completeness. :) 



Link to post

Awesome, thanks. The thing I really want that seems missing is the ability to use {selection}, specifically for formatting HTML or Markdown syntax. For example, I have a snippet for creating HTML links, and I'd really love for Alfred to create the tags AROUND my text selection. 


Is this possible?



Link to post

For example, when I highlight text. Or maybe it's clearer to say "selected text"? This would be particularly useful if I could add a keyboard shortcut to a snippet.

Link to post

@chris If you create a workflow, you can configure a Hotkey Trigger to take the currently selected text in macOS, then you can connect this into a "Copy to Clipboard" object set to automatically paste. Put your snippet content in that second object, and use {query} for the scooped in selected text.

Link to post
15 hours ago, chris said:

Or maybe it's clearer to say "selected text"?


That's what I thought. But I don't think it's possible to type a snippet trigger and have selected text at the same time.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...