Questions tagged [code-snippets]

For issues relating to the creation, use, and maintenance of code snippets.

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.

Snippets can be created and used in many newer IDEs to insert a nearly functional code. With placeholders it is then possible to tab through the missing parts and fill in the variable names of other missing code parts.

For a fast practical use of a theoretical concept it is often preferred to show it on a snippet as an excerpt of the used code with the variable names foo and bar.

1929 questions
0
votes
0 answers

Google+ snippet generator doesn't show code

Here developers.google.com/+/web/snippet/ it should be possible to generate Google+ snippet code. But it does not work, because the generated code is obscured by a div with the preview. See the screenshot made with Firefox (Chrome looks…
0
votes
1 answer

How to auto-escape a special char in VS Code Snippets?

I want to write a snippet for Debugging in TYPO3. This is my Snippet-Code in php.json file: "TYPO3 Extbase DebuggerUtility": { "prefix": "ee", "body": [ "\\TYPO3\\CMS\\Extbase\\Utility\\DebuggerUtility::var_dump($1,'$1');", …
MonTea
  • 1,166
  • 1
  • 13
  • 30
0
votes
1 answer

how to escape `

\$\{erro\}

` in snippets in vs code

I want to escape the characters $, {and} in the code snippet

$ {error} but the code.snippets editor of vs code shows me an error message. Can anybody help me? [The error message is the red squiggly underline signifying an "Invalid escape…

0
votes
1 answer

Create a location for Visual Studio code snippets

This is similar to How to move Visual Studio's 'My Code Snippets' folder to another drive?, but the answer there is quite old and does not seem to work any more; furthermore, the relevant paths appear to have changed. I created a code snippet via…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
0
votes
1 answer

How can I exclude two pages from optimization using Autoptimize snippet given below

I hope someone can help me here. How can I use this Autoptimize snippet to exclude two pages from optimization. The code below excludes the page…
Alex
  • 3
  • 2
0
votes
13 answers

What do you use to capture webpages, diagram/pictures and code snippets for later reference?

What do you use to capture webpages, diagram/pictures and code snippets for later reference?
prodev42
  • 6,389
  • 8
  • 32
  • 35
0
votes
1 answer

In Visual Studio Professional 2017, using 'Generate Method' after 'Show Potential Fixes', how to generate a method stub with NO body

I would like an option in Visual Studio, when selecting Show Potential Fixes on a call to a non-existent method, to create a method stud with no body. There is already a code snippet for this, "C:\Program Files (x86)\Microsoft Visual…
0
votes
1 answer

GTM Ecommerce tracking script

I have to turn this code into a script compatible with Google Tag Manager, but I don't know how to do it. I've tried to make some changes but I don't even understand what programming language this is. I'm desperate, I couldn't find anything like it…
0
votes
1 answer

How to change values only in HTML snippet in VS code?

Do you know is there a way to change values only from code HTML code snippets? You can see an example of snippet below but the real ones will be with more values and editing the values directly in code hide some risks. Is there any way to preview…
0
votes
2 answers

How can I run javascript on similar pages?

I want to use chrome snippet to run a javascript code to autofill a series of pages. The problem is after another page was opened, the code seems stopped. Instead, I need it run continually. Like this: //Page 1 form …
J.Pei
  • 141
  • 2
  • 11
0
votes
1 answer

Powerful tool to generate documentation (exact requirements included)

Short version We need a Maven Doxia alternative being able to generate good looking PDFs (at least code snippets should be properly indented and have configurable font size). Maven guys proposed maven-pdf-plugin in DOXIA-419, but it has same…
0
votes
1 answer

How to run the same snippet multiple times without page reload?

I am playing with JavaScript in "Sources" tab in Google Chrome. I have created this snippet: const sayHello = () => console.log("Hello"); sayHello(); The problem is - I can run it only one time. If I clicked on "Run" button again - an error will be…
yaru
  • 1,260
  • 1
  • 13
  • 29
0
votes
3 answers

Creating a PHP code snippet in Visual Studio Code

I'm a little confused. The file I'm editing in VScode is a php file and the code snippet below will not work if I put the snippet in the php.json, but it does, if I insert the snippet into the html.json?! Can someone please explain why the code…
user6746919
  • 67
  • 1
  • 9
0
votes
1 answer

VS Code: Snippet selection escaping of "no character"

I try to create a snippet where the NOCHAR inserts is empty. When the user selects this entry there should be NO character (not even a space). --> just to define|,a,b,c| is not really working. "Library.Internal": { "prefix":…
0
votes
2 answers

How to add custom snippets

I have defined a custom snippet as below into javascriptreact.json { "Console Logging": { "prefix": "clg", "body": "console.log('DEBUG::${1:key}', ${1:key});", "description": "Console Logging with DEBUG key" } } Now I…
Isaac
  • 12,042
  • 16
  • 52
  • 116
1 2 3
99
100