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.

0

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.

  • Please elaborate - explain how that solves the problem (answers the question). – Drew Apr 9 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 Apr 10 at 21:23
  • Put all such explanation into the question or answer. Comments can be deleted at any time. Thx. – Drew Apr 10 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy