kirklove Posted August 23, 2013 Posted August 23, 2013 Any way to have a cursor appear in the middle of a snippet after executing? For example: snippet would = "Some text here {cursor would end up here} some more text here" after you call it. Hoping for something similar to how Sublime Text does it with the $1 Grug 1
RodgerWW Posted August 23, 2013 Posted August 23, 2013 Hmm, this sounds like some scripting is required. I do not think the snippets can utilize scripts: but perhaps Andrew might be willing to add a dynamic placeholder of {cursor} to Alfred's snippets?
kirklove Posted August 26, 2013 Author Posted August 26, 2013 Ok, thanks. Would be a nice little add.
grouchal Posted September 16, 2013 Posted September 16, 2013 This would be a great addition to make snippets really useful.
jdfwarrior Posted September 17, 2013 Posted September 17, 2013 Any way to have a cursor appear in the middle of a snippet after executing? For example: snippet would = "Some text here {cursor would end up here} some more text here" after you call it. Hoping for something similar to how Sublime Text does it with the $1 No this currently isn't possible with the Snippets feature. It could potentially be done with AppleScript but it wouldn't be a very elegant solution at all.
wkoffel Posted June 13, 2016 Posted June 13, 2016 This would be a great addition (I actually assumed it was there already, it's pretty common in other snippet expansion utilities). {cursor} would be fine. Alternatively, something visual like {|} for the post-expansion cursor location.
flippidippi Posted June 15, 2016 Posted June 15, 2016 (edited) I also think in addition to this it would be awesome to allow placeholders in the text expansions like Dash does https://kapeli.com/dash_guide#introductionToSnippets Edited June 15, 2016 by flipxfx
vegasgeek Posted August 5, 2016 Posted August 5, 2016 Throwing a "Me too" in here for cursor as a placeholder in snippets.
Levi Durfey Posted August 31, 2016 Posted August 31, 2016 I would also like to see a {cursor} placeholder added to snippets—please! Grug 1
trippo Posted November 16, 2016 Posted November 16, 2016 Thank you so much.. Please insert also in the text on the footer of snippet modal
kevbonham Posted November 17, 2016 Posted November 17, 2016 On 11/8/2016 at 11:40 AM, Andrew said: {cursor} placement is available in Alfred 3.2 Very cool - thanks! I'm running into a possible bug with this feature, specifically in google docs. I'm trying to make a snippet that will expand to: [explanation] [explanation] With the cursor on the middle line. Using... [explanation] {cursor} [explanation] The result is... confusing: This doesn't happen in atom or sublime text, and if I use a different key like {date} it works completely as expected.
Vero Posted November 18, 2016 Posted November 18, 2016 @kevbonham I've had a play with Google Docs, and as suspected, the issue is down to Google Docs manipulating what you're pasting and changing it from the original snippet. If your snippet in Alfred consists of: Quote [explanation] {cursor} [explanation]<--- No further line break, your cursor can't go further than immediately after the closing bracket above When you paste it in Google Docs, an extra line break is added so your cursor can go to the line BELOW your final closing square bracket. As such, when Alfred then performs the expected number of left arrow actions to return to the right place, it isn't aware of the text manipulation Google has done, and ends up in the wrong location. It's likely that you're seeing normal behaviour in Atom and Sublime Text because they don't add unexpected line breaks. That's not something we can change, as Alfred is agnostic to the pasting destination, so you'll just need to keep the limitations of Google Docs in mind when using cursor placement. Cheers, Vero
kevbonham Posted November 18, 2016 Posted November 18, 2016 5 hours ago, Vero said: When you paste it in Google Docs, an extra line break is added so your cursor can go to the line BELOW your final closing square bracket. As such, when Alfred then performs the expected number of left arrow actions to return to the right place, it isn't aware of the text manipulation Google has done, and ends up in the wrong location. It's likely that you're seeing normal behaviour in Atom and Sublime Text because they don't add unexpected line breaks. @Vero Any sense of why it occasionally jumps where the cursor is prior to the paste action? In the last example in the gif I posted, I'm two lines below, but the paste happens inside some of the other text above it. 5 hours ago, Vero said: That's not something we can change, as Alfred is agnostic to the pasting destination, so you'll just need to keep the limitations of Google Docs in mind when using cursor placement. I understand - thanks for looking into it. I suppose I'll just have to suffer through an extra couple of keystrokes
Vero Posted November 20, 2016 Posted November 20, 2016 @kevbonham You may also want to turn on "Slow down simulated key events" in the Snippets > cog in the top right > Tweaking preferences, which ensures that Alfred waits a fraction of a second longer to allow deletions to happen fully before anything is pasted. This ensures the actions happen in the right order if the browser/Google Docs is taking longer than a native app to respond to actions. Cheers, Vero
kevbonham Posted December 26, 2016 Posted December 26, 2016 @Vero Hmm - missed this reply until just now, but I think it solves a different problem that I've been suffering through. Thanks!
kevbonham Posted June 9, 2017 Posted June 9, 2017 (edited) @Vero An odd update to this issue (cursor movement in google docs) I stumbled on that might help some people. To reiterate, I have a snippet keyed to `!expl` that looks like this: [explanation] {cursor} [explanation] Google docs does weird stuff when I use `!expl` to invoke it, but if I invoke from the clipboard viewer, it seems to work (almost) perfectly: Edited June 9, 2017 by kevbonham
Vero Posted June 10, 2017 Posted June 10, 2017 @kevbonham Based on your clip, it looks like the cursor position is being performed before the paste. When you select the snippet from the clipboard viewer, it's a simple paste with no snippet keyword to delete first. As mentioned before, did you check the box to "Slow down key events"? This ensures that there's a little more time between the deletion of the snippet keyword and pasting of your snippet content. I suspect that Google Docs is, by nature, pasting very slowly compared to a normal native application, causing this out-of-sync behaviour. For fear of sounding like I'm repeating myself, Alfred is agnostic to the pasting destination, so if Google Docs is particularly slow due to being a web-based word processor, you'll just have to keep those limitations in mind. Cheers, Vero
kevbonham Posted August 31, 2017 Posted August 31, 2017 I did try slowing down key events, which doesn't seem to make a difference. My intent was not to suggest that a change needs to be made in Alfred - this feature clearly works great in other editors (I'm starting to write more in markdown anyway, so this isn't as much of an issue for me). Just thought I'd being it up as a workaround for google docs :-)
deanishe Posted August 31, 2017 Posted August 31, 2017 Google Docs isn't the only target for which Alfred's longest delay is still too short (the same was reported for OneNote), so it might not be a bad idea for @Andrew to allow a longer delay.
Vero Posted September 1, 2017 Posted September 1, 2017 @deanishe If you take a look at my reply from earlier on, the issue with Google Docs is that it adds an extra line break when pasting (which isn't included in the snippet itself), which Alfred can't know about. On 11/18/2016 at 0:01 PM, Vero said: When you paste it in Google Docs, an extra line break is added so your cursor can go to the line BELOW your final closing square bracket. As such, when Alfred then performs the expected number of left arrow actions to return to the right place, it isn't aware of the text manipulation Google has done, and ends up in the wrong location. It's likely that you're seeing normal behaviour in Atom and Sublime Text because they don't add unexpected line breaks. That's not something we can change, as Alfred is agnostic to the pasting destination, so you'll just need to keep the limitations of Google Docs in mind when using cursor placement. No amount of delay will help if Google Docs is adding line breaks. Cheers, Vero deanishe 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now