5

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?

4
  • Always be sure to read the descriptions that appear when selecting tags! Commented Mar 7, 2014 at 22:42
  • @Charles, I am not following. What selecting tags are you referring to? Commented Mar 8, 2014 at 2:53
  • The tags on your question, which I see you've edited. When doing tag edits, an interface appears that displays the descriptions of tags as you type their names. Please always read those descriptions. (You used a tag with zero other questions that exists only as a typo, with a description asking you to use the correct tag instead.) Commented Mar 8, 2014 at 4:28
  • @Charles: Thank you for the hint. I assume the current tags are relevant to his question. Commented Mar 9, 2014 at 23:09

3 Answers 3

8

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

1

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.

1 Comment

this method only allows for typing the filename manually, not automatically

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.