Allan Xu
Allan Xu

Reputation: 9368

Visual Studio 2013: How to add file name to the output of a snippet?

I need to include the name of the file that the snippet is being inserted to the output. I looked into Code Snippet Functions (http://msdn.microsoft.com/en-us/library/ms242312%28v=vs.80%29.aspx) and the selections are limited.

Is there any way to insert the name of the file that the snippet is being inserted into to the snippet output?

Upvotes: 5

Views: 4781

Answers (3)

Davood V
Davood V

Reputation: 116

You can add ${1:${TM_FILENAME_BASE}} tag in json snippet file to get file name and add it to output of snippet.

Upvotes: 8

Jim Buck
Jim Buck

Reputation: 2444

It does not seem possible to do with snippets, but it is possible with Item Templates. See this post for more information.

Upvotes: 2

torpederos
torpederos

Reputation: 841

Maybe this could help: File Header code snippet or this one: Code Snippet Functions. In short using Declariations->Literals and Code snippet functions should resolve your problem.

Upvotes: 1

Related Questions