'How to get a file name into a code snippet in Visual Studio 2019

I am preparing a code snippet in Visual Studio 2019 Community.

I want one of parameters for my snippet was a file name, where I want the snippet to be inserted (let's call it a "target file name").

If that is possible to get the file name as a replaceable parameter in the snippet, how do I do that?

By replaceable parameters I mean the ones with $some-parameter$ in the snippet.

Any ordinary parameter normally would be acquired from an <Declaration> section of the snippet. I am looking for a way to somehow fetch the "target file file" name from the view where I intend to put the snippet.

P.S. I did study the intro provided by the Microsoft Walkthrough: Create a code snippet and hadn't find anything that could help here. I checked all the code snippets provided in Visual Studio too.



Solution 1:[1]

i find this solution and works, for me, i hope works for you: You can add ${1:${TM_FILENAME_BASE}} tag in json snippet file to get file name and add it to output of snippet.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chris Catignani