Questions tagged [vscode-snippets]

For issues relating to the creation, use, and maintenance of code snippets in Visual Studio Code

Overview

A snippet is a small region of re-usable source code, machine code or text. Ordinarily, these are formally-defined operative units to incorporate into larger programming modules. Snippets are often used to clarify the meaning of an otherwise "cluttered" function, or to minimize the use of repeated code that is common to other functions.

See also

384 questions
1
vote
3 answers

How can I create VS Code snippets that consume pre-existing text placed before the snippet prefix and use it in the snippet body?

I want to make snippet for console.log(variable) but instead to have prefix I want to make this with "suffix". Here's an example: var name = "Marco"; var car = "Volvo"; name.log > TAB > console.log(name); When I write my variable "name" after that…
1
vote
1 answer

Regex - Adapting a VS Code Snippet to convert a label to downcase

I am trying to create a snippet for VS Code that creates a label based on the "Section" name: "Headings | Section": { "prefix": "sec", "body": [ "\\section{${1:section_name}} % (fold)", …
Terry Panda
  • 113
  • 4
1
vote
0 answers

Can anyone help me convert this snippet from C to an x64 .dll?

I'm having trouble converting a .c file to a .dll file with VSCode. I think the problem is that MinGW is not able to compile on x64. OSError: [WinError 193] %1 is not a valid Win32 application Any ideas? #include #include…
1
vote
2 answers

VSCode TextEditorDecoration API not rendering white spaces

I am trying to create copilot like ghost snippet suggestion using vs code TextEditorDecoration, but I am not able to figure out how to fix below issues White spaces not getting rendered Not rendering decorations after the last line. Currently,…
1
vote
2 answers

Creating a vscode snippet regex for file name

I am building my own snippet in vscode. I am not the best with regex so I was using chatgpt to help me build regex. However, I am unable to create a regex that will convert my file name such as: AppInput.tsx into app-input Currently, I have this…
User123123
  • 485
  • 1
  • 5
  • 13
1
vote
2 answers

VSCode Snippets not working inside Vue's template/script/style tags

I'm new to vscode and can't get snippets to work properly inside of Vue files. They work in /snippets/vue.json: { "": { "prefix": "template", "body": [ "" ] } } This works, as long…
Artur Müller Romanov
  • 4,417
  • 10
  • 73
  • 132
1
vote
0 answers

ES7+ React/Redux/React-Native snippets not working in jsx files in vscode

The vscode ES7+ React/Redux/React-Native snippets extension stopped working inside .jsx and .tsx files. When I disabled the built-in extension TypeScript and JavaScript Language Features, the snippets worked as normal. Is there a fix for this? I…
K i
  • 539
  • 5
  • 12
1
vote
0 answers

VSCode built-in snippets fail to to show when consecutive letters are typed

If I type one letter of the trigger/prefix, the snippet suggestion works to show the built-in snippets from extensions. But, once I type the next letter in the trigger/prefix...the built-in snippet from the extension is gone. Meaning, it is no…
1
vote
1 answer

Reactjs snippets not working in Visual code

I am working on Reactjs and using nextjs framework,Right now i am trying to use "snippets",For example i want if i type "RFCE" then react functional component export code should display, Actually "ES7+ React/Redux/React-Native snippets" extension…
1
vote
2 answers

VSCode snippets: How to edit each line of text from clipboard before pasting?

Is there a way in visual studio code to edit each line of text from the clipboard before pasting? I want to create a snippet that will run at the appropriate key combination, edit the text that is copied, and then paste it. For example: INPUT - I…
1
vote
2 answers

What is the scope used in VSCode snippets for vue files?

I'm creating a snippet file for my project. However, I only want to defined the scope for some snippets for Vue Files only. Of course I know I can omit the scope property to apply it in all kinds of files, but I don't want that. I tried different…
JotaPardo
  • 817
  • 9
  • 27
1
vote
1 answer

Make a vscode snippet for switch with number of cases

I'm looking for a way to make a snippet for a switch where you can say how many cases you want. Like: switch2 gives switch (variable) { case "value": # code... break; case "value": # code... break; …
Viper
  • 13
  • 3
1
vote
0 answers

VS Code Custom Snippets parameters hints

I am creating my own snippets for my script, and would like to make hints in the parameters. "GDX Round": { "prefix": "gdxround", "body". "GDX.Round(${1:int}, ${2:round_decimal})" ], "description": "GDX…
Gdany
  • 11
  • 2
1
vote
0 answers
1
vote
2 answers

VS Code Branching Snippet Completion Items Extension

I am attempting to add Completion snippets to an extension I'm writing based on the completions sample ( https://github.com/microsoft/vscode-extension-samples/tree/main/completions-sample ). I would like to have it branch complete. In my extension,…