Skip to content

Indentation help with blank line #489

@mkleehammer

Description

@mkleehammer

I have some Python functions that accept SQL statements, so I have some templates that insert a triple quoted string. For example, the result I'm trying to achive is:

cnxn.execute(
    """
    |     # <-- caret here
    """)

I have a template with key "execute" and it usually works, but not always:

# -*- mode: snippet -*-
# name: execute
# key: execute
# expand-env: ((yas-indent-lines 'auto) (yas-also-indent-empty-lines t))
# --
execute(
    """
    $0
    """)

With this, entering "cnxn.execute" at column 0 results in:

cnxn.execute(
    """   
        |
        """)

Within a function they are lined up however.

I've tried combinations of indentation markers, fixed, auto, nil, etc. and cannot find a
combination that works at column 0 and at other columns. Each either ends up like this or
reversed where the closing quotes are indented before the opening.

the behavior I'm looking for is almost fixed with a marker:

  • The line with "execute" is already indented correctly so it shouldn't change.
  • The opening quotes should be lined up according to mode. They could be much further back if
    "execute" is at the end of a long line.
  • The empty line with $0 and the closing quote need to be lined with the closing, disregarding
    the mode. Basically like fixed, but fixed from the first indented line.

Am I missing a combination or a feature?

Thanks.

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