textmate / bugs

Bug tracker for TextMate (not its bundles, nor tracking feature requests)
4 stars 0 forks source link

Tab trigger does not expand when moving tab stops #30

Closed yuuq closed 6 years ago

yuuq commented 6 years ago

Steps to reproduce:

  1. Make below snippet.

Tab Trigger: now

Snippet body: isoD$1 $0

  1. Expand above snippet. now[hit tab]

  2. Snippet is expanded like below. (^) indicate cursor position.

isoD
    ^
  1. Press tab key. This does not expand isoD snippet, it move to next tab stop.

Expected result: Expand snippet with tab trigger.

Actual result: Does not expand snippet and move to next tab stop.

Environment: macOS version: 10.13.6 (17G65) TextMate version: 2.0-rc.10

sorbits commented 6 years ago

This behavior is intentional as when we introduced recursive snippet expansion we had issues with existing snippets where the text before placeholders would sometimes be matched as a tab trigger.

If you want current date in a snippet you can insert command output using backticks, e.g.:

`date +%Y-%m-%d`$1
$0
yuuq commented 6 years ago

Thank you for replying.

I understand why recursive snippet can't expand.

Thank you for tips, but I actually do time tracking workflow with snippet and command.

I have current time command. Tab trigger: now Command body:

#!/usr/bin/env bash
date "+%H:%M" | xargs echo -n

And read entry snippet. Tab trigger: re Snippet body:

`date "+%H:%M"` - now$0
`pbpaste`

Above pbpaste is copying markdown formatted link from Safari bookmarklet.

I want to move cursor below expanded read entry to write thoughts.

You say recursive snippet can't do, so I made below macro and assign ⌘⌥+↓ keyboard shortcut.

(
    {   command = 'selectParagraph:'; },
    {   command = 'moveDown:'; },
    {   command = 'moveDown:'; },
)

This works fine, but I'm curious is there any much more streamlined way?

Thank you for your help.

sorbits commented 6 years ago

If I understand the workflow correctly, how about something like this:

 `date "+%H:%M"` - ${1:`date "+%H"`}:${2:`date "+%M"`}
 `pbpaste`
 $0

Or is the issue that you expand the snippet when you start work, and then you just leave the insertion point at ‘now’ until you finish the work, and would prefer to just press tab when you are done with the work and then have current time inserted?

On 30 Sep 2018, at 8:14, Yuu Q wrote:

Thank you for replying.

I understand why recursive snippet can't expand.

Thank you for tips, but I actually do time tracking workflow with snippet and command.

I have current time command. Tab trigger: now Command body:

#!/usr/bin/env bash
date "+%H:%M" | xargs echo -n

And read entry snippet. Tab trigger: re Snippet body:

`date "+%H:%M"` - now$0
`pbpaste`

Above pbpaste is copying markdown formatted link from Safari bookmarklet.

I want to move cursor below expanded read entry to write thoughts.

You say recursive snippet can't do, so I made below macro and assign ⌘⌥+↓ keyboard shortcut.

(
  {   command = 'selectParagraph:'; },
  {   command = 'moveDown:'; },
  {   command = 'moveDown:'; },
)

This works fine, but I'm curious is there any much more streamlined way?

Thank you for your help.

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/textmate/bugs/issues/30#issuecomment-425697629

yuuq commented 6 years ago

Yes, your second interpretation is correct. I expand snippet before read some web page in Safari, and after I read web page I press tab key to expand 'now' for insert current time(end of read time).

sorbits commented 6 years ago

What you can do is something this:

 `date "+%H:%M"` - ${1:now}
 `pbpaste`
 $0

Then after inserting the snippet you will have now be selected. Press arrow right and then tab will work to expand the tab trigger.

On 30 Sep 2018, at 10:10, Yuu Q wrote:

Yes, your second interpretation is correct. I expand snippet before read some web page in Safari, and after I read web page I press tab key to expand 'now' for insert current time(end of read time).

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/textmate/bugs/issues/30#issuecomment-425703203

yuuq commented 6 years ago

Wow, very clever snippet! I changed snippet and works great😁

Thank you for your kind support.

By the way, your new project, Genie is very promising. I like customization feature.