G
G
Governor2020-09-21 15:04:52
Snippets
Governor, 2020-09-21 15:04:52

How to write a script (snippet) for vscode?

Is it possible to make such a script in vscode (snippet or macro, it doesn't matter), so that on pressing the keys, where the cursor is located, insert text containing the parameters of the current function?
Let's say there is a trace. function:

function main(name, age)
{
  |  //тут курсор
}


and if the cursor is inside this function, the script should insert a trace in place of the cursor. text:
param1: name
param2: age

Suggest an idea if possible.

In the standard snippet, when you enter "/**", this is implemented. How can I see the implementation of a non-custom snippet?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-10-02
@RomanTRS

This is easily done using the standard snippet system.
Briefly:
1. press F1
2. start typing 'snippets'
3. Select 'Configure User Snippets' from the options
4. Select a file with snippets or create a new one
5. Add a new snippet, following the example in the opened file
Profit!!
For details, see here: https://code.visualstudio.com/docs/editor/userdefi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question