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
0 answers

How to add snippet in slack?

I know what you think, you will probably give me this slack snippet documentation, but sadly I've been here and it's not the one I'm talking about. I'm talking about snippet like in vscode, in which we can save large amount of prepared text. And…
1
vote
2 answers

vscode snippets: How to link a position in the snippet to a tabstop?

I want to create a snippet that prints the value of a variable for debugging purposes. this is what I came up with: { "Debug": { "prefix": ["db"], "body": ["console.log(\"$1 :\", $1)"] } } When I use this snippet cursor goes between the…
Arman
  • 720
  • 2
  • 7
  • 18
1
vote
2 answers

VS Code snippet interprets variable as string

I'm writing a snippet in VS Code using variable transforms. I want to replace a pattern that occurs in some text (in this case text copied on the clipboard) with a variable that inserts the name of the file without extensions (for example:…
Joe
  • 345
  • 1
  • 14
1
vote
2 answers

how to make a custom comment style in vscode

I got a source code commented like below. // //------------------------------------------------------------------------------ // //======================= Variable Declaration ================================= Is there any way to make a comment…
Mahi
  • 1,297
  • 1
  • 14
  • 28
1
vote
2 answers

How can I create a VSCode snippet to automatically insert namespace of files inside my src folder?

First off, I have the following psr-4 declaration for the src folder inside my composer.json file: "autoload": { "psr-4": { "Src\\": "src/" } }, I would like to build a VSCode snippet that autogenerates the namespace…
assensi
  • 352
  • 1
  • 6
  • 17
1
vote
1 answer

In Visual Studio code, how do I assign a single keyboard shortcut to multiple languages?

I couldn't find anybody asking how to do this: if I'm using typescript, I may want a keyboard shortcut for generating the boilerplate of an "if statement" like so: if (/* cursor starts here */) { /* selected text goes here */ } But if I'm using…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
1
vote
1 answer

Transfom file path into Ruby nested Class using regex syntax transform

I try to change this (VSCode RELATIVE_FILEPATH variable): app/service/namespace/important_thing/my_class.rb into this: Namespace::ImportantThing::MyClass What I got so…
1
vote
2 answers

How to escape python block comments when creating vscode snippets?

I created a vscode snippet for a a python function definiton and I am wondering if this is the only and/or recommended way of escaping the python block comments (""" """). global snippets file { "def ": { "scope": "python", …
RSale
  • 463
  • 5
  • 14
1
vote
0 answers

VSCode Snippets: Remove Char After Capitalizing?

Is there a way to create a chain of regex to capitalize a string and than remove all characters - from it in Visual Studio Code snippets? "body": [ "const ${TM_FILENAME_BASE/([a-z])(\\w+)/${1:/upcase}$2 /['-.']// /g}; ] Wanted…
user17143939
1
vote
1 answer

Facing problem in Variable Transformation in VS Code snippets

I'm having the below code of a global-snippet of VS Code "prints formated path": { "prefix": "pp", "body": [ "$BLOCK_COMMENT_START", "File Path -> \"${TM_FILEPATH/\\///g}\"", "$BLOCK_COMMENT_END", ], …
Aman
  • 343
  • 2
  • 8
1
vote
1 answer

I cannot disable the cloudformation snippets/suggestions in VS Code

I am trying to disable (an annoying) AWS Cloudformation suggestions/snippets because they are cluttering my suggestions: It seems impossible to find where these are coming from: I disabled the AWS Plugins, no help. Tried to find the snippets with…
1
vote
7 answers

ES7 React/Redux/GraphQL/React-Native snippets not working

I'm unable to use ES7 React/Redux/GraphQL/React-Native snippets for some reason even though I have installed the extension required.
Digamber negi
  • 407
  • 1
  • 7
  • 20
1
vote
0 answers

VSCode add already existig code snippets from another folder

I have a very large project with hundreds of files and complex folders structure. Code snippets that are convenient for me have been created there. Sometimes I like to change the scope to a specific nested subdirectory (Open this folder in another…
aleha_84
  • 8,309
  • 2
  • 38
  • 46
1
vote
1 answer

what's wrong with this chained snippet for visual studio code?

i am trying to make a snippet to declare bemit components so when i create a new one, i just have to write the prefix "new-bemit-component" and then for example with the file "_c-indice" _ for partial element, c- for component and then the name, the…
1
vote
2 answers

Modify the first letter of an argument in a user snippet in VSCode

I am using the prefix prop to generate: private $1 $2; public void set$2($1 $2) { this.$2 = $2; } public $1 get$2() { return $2; } This is my snippet: "Add a property" : { "prefix": "prop", "body": [ "private $1 $2;", …
kesarling He-Him
  • 1,944
  • 3
  • 14
  • 39