AndreaCrotti / yasnippet-snippets

a collection of yasnippet snippets for many languages
GNU General Public License v3.0
1.15k stars 461 forks source link

Indentation help with blank line #489

Open mkleehammer opened 5 months ago

mkleehammer commented 5 months ago

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:

Am I missing a combination or a feature?

Thanks.