Skip to content

Field with Transformations is Sticky #1206

@axbycc-mark

Description

@axbycc-mark

Consider this snippet.

# -*- mode: snippet -*-
# name: example
# key: example
# --

${1:variable} ${2:$$(unless yas-modified-p (format "++%s" (yas-field-value 1)))}
$0       

The default expansion is variable ++variable. The intended usage is in defining a c-style loop snippet. Usually when you first enter into a tab stop, typing x will remove the placeholder and replace it with x. However, on the second tab stop in this snippet, typing x will leave you with variable ++variablex instead of the more consistent variable x.

Hence, making a field value with a transform makes it "sticky" and it doesn't behave like other fields.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions