0

I would like to know how to append a default string to a placeholder.

For example, I currently have:

# -*- mode: snippet -*-
# name: render template
# key: rt
# group: Flask
# contributor: Jon Rostran
# --
render_template("${0:index.html}")

But I would like for rt to expand to render_template("|.html") where the | is my cursor position after expansion.

1 Answer 1

1

Was making things harder than I thought. Solved it with this render_template("$0.html")

EDIT:

Explanation

The default expansion of render_template("${0:index.html}") is render_template("index.html"), but I would like to save myself from overriding "index.html" and manage typing the .html extension by default. Thus, render_template("$0.html") allows me to type only the name of the file so that after expansion I start typing here render_template("|.html"), without overriding and typing .html part again.

3
  • Please elaborate - explain how that solves the problem (answers the question).
    – Drew
    Commented Apr 9, 2019 at 22:40
  • The default expansion of render_template("${0:index.html}") is render_template("index.html"), but I would like to save myself from overriding index.html and manage typing the .html extension by default. Thus, render_template("$0.html") allows me to type only the name of the file so after expansion I start typing here render_template("|.html"), without overriding and typing .html again.
    – user20304
    Commented Apr 10, 2019 at 21:23
  • Put all such explanation into the question or answer. Comments can be deleted at any time. Thx.
    – Drew
    Commented Apr 10, 2019 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.