AddAnyFile icon indicating copy to clipboard operation
AddAnyFile copied to clipboard

Custom templates dollar ($) symbol

Open jasontaylordev opened this issue 3 years ago • 1 comments

When creating a custom template I don't understand how the dollar ($) symbol is used. I thought perhaps it was to specify the cursor position or preserve whitespace - but couldn't confirm that behaviour.

Please can someone advise? Thanks. 😀

jasontaylordev avatar Sep 12 '22 06:09 jasontaylordev

@jasontaylordev You are correct, the dollar symbol ($) is used to mark where the cursor is placed when the file is opened after creation. The position of the first $ is returned from the function and used after the file is opened in the editor.

https://github.com/madskristensen/AddAnyFile/blob/8a8443fbf0f5953cf83849a489350b0e42ca2e86/src/AddAnyFilePackage.cs#L198

If you're wondering how to keep a dollar sign in your template, such as when you have an interpolated string in your template, you just need to double them up so you have two dollar signs in the template, or include a single dollar sign to specify the cursor position somewhere before the interpolated string.

FXZFun avatar Mar 05 '24 19:03 FXZFun