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
24
votes
1 answer

VS Code snippet - escape ${file}

I'd like to create a snippet in VS Code, which includes exact string ${code}. However, when I enter it in this form, VS Code tries to interpret it as snippet parameter. How should I escape it properly?
Spook
  • 25,318
  • 18
  • 90
  • 167
23
votes
6 answers

Xcode built-in snippets edit

Is there a way to edit Xcode's built-in snippets? There is an edit button, but pressing it doesn't seem to allow changing the snippet's text. Any insight is appreciated.
Martin Cote
  • 28,864
  • 15
  • 75
  • 99
23
votes
2 answers

Where are the MVVM Light snippets?

It seems that snippets of MVVM Light are not installed when we use Nuget to install MVVM Light Toolkit. Where can I find them ?
JYL
  • 8,228
  • 5
  • 39
  • 63
21
votes
2 answers

How to lower case a Visual Studio Code Snippet variable?

I've build some snippets to generate a fields for a setting class. I'm now using 2 variables - $setting$ and $Setting$ - to generate names for the property and the backing field. I like to use a single variable, because the only difference is that…
Kees C. Bakker
  • 32,294
  • 27
  • 115
  • 203
20
votes
6 answers

Atom Editor: multiple snippets

This is such a simple question but I can't find any documentation besides the readme. How can I have multiple custom snippets in Atom Editior: For example I have this in my snippets.cson right now '.source.js': 'Normal Comment Block': …
TheMcMurder
  • 758
  • 3
  • 9
  • 22
20
votes
3 answers

Can I define custom "surround with" templates in Visual Studio 2008?

Can I define custom "surround with" templates in Visual Studio 2008?
Piotr Owsiak
  • 6,081
  • 8
  • 39
  • 42
19
votes
9 answers

Recommended online snippet manager

I am looking for an online snippet manager for work, personal use and inspiration. My primary needs are google/facebook login, fontification of various programming languages, privacy control, social network integration. What's the recommendation?
Christian Madsen
  • 1,688
  • 4
  • 17
  • 30
19
votes
2 answers

How to include a code snippet in a beamer presentation?

What's the best way to include some code snippets in a beamer presentation? I've already tried verbatim, and lstlisting environments - both destroyed my presentation.
mik01aj
  • 11,928
  • 15
  • 76
  • 119
18
votes
1 answer

Recording a 'macro'? or a series of actions in Visual Studio Code?

I would need something like this. Once I create a folder within a project. A React Project for example. I could select that folder and run some kind of macro or series of actions that would do this. Provided that the name of the folder is Component…
18
votes
4 answers

Ace Editor manually adding snippets

TL;DR I am trying to manually trigger ace editor snippets through a function call, rather than the conventional approach (keyboard keys). Explanation I need a function that takes in the editor and a snippet string as the parameters, and adds that…
Ali Ashraf
  • 759
  • 1
  • 8
  • 17
18
votes
7 answers

Automatically create #region with same name at #endregion

I'm wondering if there is a way to make #region Some Region #endregion Some Region. If there is no way for doing it then maybe is it possible with Resharper? Hope it's clear what I'm trying to achive here. Edit:
Harry89pl
  • 2,415
  • 12
  • 42
  • 63
18
votes
3 answers

Live Template fore Intellij IDEA for Iterating through Map

We can iterate through collection easily by pressing Ctrl+Alt+T, And then I wanted to create such template for iterating through map: I wrote these lines to template text box: for (Map.Entry<$ELEMENT_TYPE$> $VAR$ : $SELECTION$.entrySet()) { …
Jama A.
  • 15,680
  • 10
  • 55
  • 88
18
votes
1 answer

What's wrong with this code snippet?

I tried to import this into the Code Snippets Manager and got the error "The snippet files chosen were not valid." Since this is my first snippet, and the error message doesn't deign to point out why the snippet is not valid, I am at a…
Thom Smith
  • 13,916
  • 6
  • 45
  • 91
17
votes
2 answers

Find my custom code snippets Xcode 6?

I know where the system default snippets are, but my two new ones cannot be found. Basically, I want to add in my collection of previous snippets. I made two new ones just to be able to find them. Didn't work. Any suggestions?
malaki1974
  • 1,605
  • 3
  • 16
  • 32
17
votes
2 answers

How to move Visual Studio's 'My Code Snippets' folder to another drive?

A simple question for which I couldn't find a setting or an answer: I relocated my Documents folder in Windows to another drive. How do I change the My Code Snippets folder path in Visual Studio 2012 from the default to the new location? The…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157