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
3
votes
2 answers

vscode: how to make text after snippet *not* selected?

When a snippet (for whatever language) is triggered, and the cursor is moved to a tab-stop, the area is "selected" (that is, you are still in "snippet mode" where you can go to another tab-stop). But I would like to get out of this "snippet mode"…
milanHrabos
  • 2,010
  • 3
  • 11
  • 45
3
votes
1 answer

How do I insert tabulation inside VS Code snippet?

I have a code snippet in VS Code, looks like this "JS arrow function": { "scope": "javascript, typescript", "prefix": "af", "body": [ "const ${1:name} = (${2:props}) => {", " $3", "}" ], "description":…
3
votes
2 answers

Implement VSCode snippet for C++ header guard

I tried to create a snippet in VSCode to quickly include C++ header guards. For example with a file path is C:\workspace\src\chrome\browser\ui\webui\settings\about_handler.h The snippet is expected to generate like this: #ifndef…
Justin
  • 149
  • 1
  • 11
3
votes
1 answer

How to apply more than on transform on visual studio code snippets?

Hopefully you have some experience with visual studio code snippet writing if you have opened this and you can help me. I am trying to get better at writing visual studio code snippets. This is one I have at the moment: "Styled Template": { …
3
votes
2 answers

LaTeX fraction snippets in VSCode

Context For the past 18 months, I've been using the LaTeX Workshop extension of VSCode for all my LaTeXing needs. Up to this point, I've primarily used it for longer-form articles and reports, and sporadically for note-taking purposes in class. I've…
Shady Puck
  • 133
  • 1
  • 5
3
votes
4 answers

How to remove IntelliSense suggested snippets introduced by extension (or built-in)

Normally, I want to see suggested IntelliSense snippets when typing and this works nicely. However, some extensions I installed introduce a lot of snippets I will never use and they bloat the IntelliSense suggested list. I found no way so far to…
Ev0oD
  • 1,395
  • 16
  • 33
3
votes
1 answer

In VS code snippet how to reuse a transforms like a variable to avoid write the transform again and again?

For example I want to reuse this transform like a variable in my snippet instead of write the transform again and again ${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/} "example": { "prefix": "example", "body": [ …
3
votes
1 answer

VSCode snippet, transform lowercase string delimited by underscores into CamelCase?

I'm writing a custom snippet in VSCode to help me define custom class methods easily. I need to be able to enter a string 'formatted_like_this' and have the regex transform that string in certain places so that it becomes 'FormattedLikeThis'? The…
3
votes
1 answer

VSCode personnal shortcuts not working in notebook editor

I added a shortcut in vscode to insert a small pattern in my code: { "key": "ctrl+alt+z", "command": "editor.action.insertSnippet", "when": "editorTextFocus", "args": { "snippet": "#ZZZ ${1:comment}" } } This shortcut…
3
votes
1 answer

How to extract a portion of TM_FILENAME_BASE

I'm trying to write a snippet to quickly/easily generate an interface for a repository. If I name the file IFooRepository I'd like the snippet to place the word Foo in a few areas. I'm assuming this can be achieved by transforming the…
3
votes
2 answers

HTML end tags doesn't comes in snippet inside Vue templates

I am very new to Vue Js (Node Version v10.16.3) and (NPV version 6.9.0) and I couldn't figure out how to fix HTML snippet issue. I installed Vetur 0.22.2 and VueCSCodeSnippets 1.8.0 but still when i type closing/end tag doesn't come after. I need…
AliAzra
  • 889
  • 1
  • 9
  • 28
3
votes
1 answer

In VSCode snippets, how can I capitalize the value of another user-defined variable?

I'm in VSCode trying to make snippets and get my head around some of the new regex replacement syntax. What I want to do is populate parts of my template based on the filename. I can strip the unwanted extensions okay, but I can't capitalize the…
Sebastian Nemeth
  • 5,505
  • 4
  • 26
  • 36
2
votes
1 answer

VSCode project snippets not working as expected on Windows

I start typing the prefix "conso" and I would expect that the snippets suggestions will show at the top. In fact, it is working on MacOS. However, on Windows no snippet suggestions are shown. .vscode/snippets/typescript.json { "console": { …
Shankar CJ
  • 29
  • 2
2
votes
1 answer

Failed to parse json file, possibly due to comments or trailing commas

Whenever i am clicking on Run and Debug in vs code getting this error. "Failed to parse json file, possibly due to comments or trailing commas." how can i solve this? I tried deleting the .vscode folder and doing it again but still getting this…
2
votes
1 answer

Regex expression for hyphenating file name in a VS Code snippet

I’m trying to create a regex for a custom VS Code snippet I’m writing. Im taking the file name that’s in camel case format and modifying it so a hyphen separates each word (before the uppercase letter) and then transforms the entire thing to…
Kate
  • 21
  • 2