Jump to content
roads

Using Dynamic Placeholders In Snippets

Recommended Posts

dear mom and dad,

 

a dynamic I miss is to place the cursor at a defined place in the snipet after it gets pasted. Is that funcionality in there and I just missed it?

Share this post


Link to post

No, this functionality does not exist in Alfred.

 

As I understand, placing the cursor in a text snippet is much less reliable than pasting (which Alfred does now). It would require using OS X's Accessibility API to actually simulate moving the cursor, which feels like a hack.

Share this post


Link to post

Apps like typinator can do this, I think even Launchbar can by placing a {^}. So we don't misunderstand each other, the feature request is to paste the snippet and have the cursor jump to the desired point within the snippet. I think you think I mean wargames like cursor typing which I am not.

Edited by roads

Share this post


Link to post

As Tyler suggests, Alfred doesn't use OS X's Accessibility features for text interaction, and as such, cannot reposition the cursor after pasting.

 

Having said that, depending on what you need to do, you could create a workflow which pastes a text snippet and populates additional text within the snippet in place (I assume that's why you want to reposition the cursor?)

 

Cheers,

Andrew

Share this post


Link to post

What I need it for Andrew is to adjust the snippet.Cursor movement is time consuming maybe even needs scrolling. Using the mouse is the option which isnt automatic either. A simple example would be.

 

Dear  <place cursor here>

 

blablabla

 

kind regards,
 

Peter

Edited by roads

Share this post


Link to post

Understood. Does Typinator support AppleScript automation?

 

I use TextExpander, and it would be pretty easy to write a workflow for that using its AppleScript support.

Share this post


Link to post

That's the wrong kind of API. That's how to write scripts for Typinator to run. The app needs to support being scripted to write a workflow for it.

 

For TextExpander, for example, it'd be pretty easy to write a workflow that could search your snippets by name/abbreviation and trigger them from within Alfred. Helpful if you often forget the abbreviations.

Share this post


Link to post

Now that Alfred 3 supports text expansion, and uses OS X's Accessibility features, is it possible to place the cursor?

 

In the past I've used textExpander for this, but I'm looking forward to getting rid of it as soon as alfred can support placing the cursor. :-)

Share this post


Link to post

Now that Alfred 3 supports text expansion, and uses OS X's Accessibility features, is it possible to place the cursor?

 

In the past I've used textExpander for this, but I'm looking forward to getting rid of it as soon as alfred can support placing the cursor. :-)

 

 

This isn't currently possible but it is something we'll be keeping an eye on. :)

 

Cheers,

Vero

Share this post


Link to post

Vero, thanks for your response! I tweeted at you as well, you can disregard. :-)


 


Loving alfred 3 so far. Hope that you can add cursor placement support to text expansion in the future! :-)


Share this post


Link to post

I'd like to see this feature too. I'm using atext and usually use cursor placement in to speed up my coding workflow. 

Here's some of my snippet examples :

<!-- {cursor} --?> 

<div class="{cursor}"></div>

<p>{cursor}</p>

Share this post


Link to post

Oh, I thought this would already be implemented when I saw the first time the new snippet-feature announcement.

 

Would like to see this in the new snippet-insertion feature, too!

 

Examples:

 

1. Define (single) target of cursor

<p>{cursor}</p>

2. Define (multiple) targets to jump for cursor

Jumping via TABulature hotkey.

for({cursor_pos0}; {cursor_pos1}; {cursor_pos2}) {
    {cursor_pos3}
}

Have a nice day!

Share this post


Link to post

Oh, I thought this would already be implemented when I saw the first time the new snippet-feature announcement.

 

Would like to see this in the new snippet-insertion feature, too!

 

Examples:

 

1. Define (single) target of cursor

<p>{cursor}</p>

2. Define (multiple) targets to jump for cursor

Jumping via TABulature hotkey.

for({cursor_pos0}; {cursor_pos1}; {cursor_pos2}) {
    {cursor_pos3}
}

Have a nice day!

 

Cursor movement like this is best done in the editor itself. For example, Sublime Text allows snippets to have many cursor locations and you tab to each one to fill them in. That would never work for any generic application. It works for Sublime because the program is in complete control of itself already. It's not hacking the UI to get an effect.

 

My Quiver Snippet workflow (and the plain file version as well) uses Keyboard Maestro or TextExpander (which I quit supporting since I no longer use it) to move the cursor to a single location. The Keyboard Maestro solution is buggy since it is forcing the back arrow key. For short distances, it does fine. But for a lot of text, it misses quite often. Part of the bugs is that you are not sure when the system will paste the text to start the backtracking. When the system is running hard, even TE got it wrong a lot of the time. But, multiple locations would never work by stuffing the input buffer as these programs do.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...