I am not looking for a snippet that creates a method or function, I want a snippet that inserts the name of the method/function automatically.
Precisely, I would like something like this:
console.log('${TM_METHODNAME}: ${1}')
Unfortunately, TM_METHODNAME
is not part of the default set of variables.
There doesn't seem to be an extension available for that either.
Maybe a compromise would be to use TM_SELECTED_TEXT
, although I don't understand how it works, as when typing the snippet prefix, the selected text is obviously erased.
In programming practice, "snippet" refers narrowly to a portion of source code that is literally included by an editor program into a file, and is a form of copy and paste programming. This concrete inclusion is in contrast to abstraction methods, such as functions or macros, which are abstraction within the language.
Create your own snippets# To create or edit your own snippets, select User Snippets under File > Preferences (Code > Preferences on macOS), and then select the language (by language identifier) for which the snippets should appear, or the New Global Snippets file option if they should appear for all languages.
Applies to: Visual Studio Visual Studio for Mac Visual Studio Code. Code snippets are small blocks of reusable code that can be inserted in a code file using a right-click menu (context menu) command or a combination of hotkeys.
A code Snippet is a programming term that refers to a small portion of re-usable source code, machine code, or text. Snippets help programmers reduce the time it takes to type in repetitive information while coding. Code Snippets are a feature on most text editors, code editors, and IDEs.
As of v1.20 you can use CLIPBOARD
as a variable, see v1.20 release notes so you could copy the method name first and have it ready to use in the snippet. I think at this point that is your only option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With