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
16
votes
5 answers

List of Functional code snippets for Procedural Programmers?

Sometimes I still get stuck trying to translate procedural code into functional code. Is there a list of functional idioms/snippets that are mapped to procedural idioms/snippets? Edit Since there doesn't seem to be a centralized website of these…
Unknown
  • 45,913
  • 27
  • 138
  • 182
16
votes
10 answers

Built-in snippet not working in VS Code for React

I am coding a React page with VS Code. Suddenly, some snippets like rfce started not working even if it's never given me problems. I don't know what's wrong. picture of before picture of now What I did recently was just updated react-router-dom to…
SteakOverflow
  • 193
  • 1
  • 2
  • 9
16
votes
3 answers

Is there any shortcut for // MARK: in Xcode like there is for /// <#Description#>?

Is there any keyboard shortcut for '// MARK:' in swift like there is for header doc '/// Description' ?
Mr. SS
  • 387
  • 2
  • 19
16
votes
1 answer

Running snippets in chrome after page reload

Is there any way to make chrome or any other browser run a snippet right after a page reloads? Thanks!
16
votes
1 answer

Visual Studio toolbox code snippet

Hi I am trying to create code snippets in my tool box. I dragged code from my code view to toolbox, renamed snippet code to name exSnippet1. I am trying to find out -- > Instead of dragging and dropping Can I add code snippets to toolbox dynamically…
Kurkula
  • 6,386
  • 27
  • 127
  • 202
16
votes
3 answers

With VIM, use both snipMate and pydiction together (share the key?)

I am trying to use snipMate and pydiction in vim together - however, both use the key to perform their genius-auto-completion-snippet-rendering-goodness-that-I-so-desire. When pydiction is installed, snipMate stops working. I assume its…
thornomad
  • 6,707
  • 10
  • 53
  • 78
16
votes
3 answers

How do I delete an Imported Snippet in Visual Studio?

I imported a snippet, and I want it gone. Problem is that the Snippet Manager has the Remove button grayed out when I go in and try to remove it, any ideas?
naspinski
  • 34,020
  • 36
  • 111
  • 167
15
votes
2 answers

Sharing Visual Studio code snippets amongst a team of developers

Has anyone come up with a good way to share a set of Visual Studio Code Snippets (actual .snippet files that Visual studio uses) amongst a team of developers automatically? It would be great for other developers on my team to benefit from shortcuts…
David Boike
  • 18,545
  • 7
  • 59
  • 94
15
votes
4 answers

How to remove some specific autocomplete in Sublime Text 2?

I have Sublime Text 2 installed with the Emmet package (Windows 7 64bits). When I type "wid", I want the auto-complete first suggestion to be "width". Problem is, right now it suggests "widows" which is very rarely used. How can I modify the order…
pnichols
  • 2,198
  • 4
  • 24
  • 29
14
votes
5 answers

Visual Studio 2022 Snippets not working for C#

I did a fresh install of Visual Studio 2022 v17.0.0 (.NET 6.0) and created a new WebAssembly project. Tried editing Counter component but none of the snippets work for C#. Typing cw is supposed to bring up Console.WriteLine but nothing happens,…
user1068557
  • 309
  • 2
  • 8
14
votes
8 answers

Quick and dirty way to profile your code

What method do you use when you want to get performance data about specific code paths?
Motti
  • 110,860
  • 49
  • 189
  • 262
14
votes
1 answer

How to add snippet to Visual Studio Code for multiple languages?

I have couple of snippets that shared between js, jsx and html files. Now I have the same snippet code in 3 files. Is it possible to create snippet and specify to what files/types it should be applicable?
Alex G.P.
  • 9,609
  • 6
  • 46
  • 81
14
votes
1 answer

Visual Studio Code snippet invalid control character

I have the following user snippet: { /* // Place your snippets for JavaScript React here. Each snippet is defined under a snippet name and has a prefix, body and // description. The prefix is what is used to trigger the snippet and the body…
Gurnzbot
  • 3,742
  • 7
  • 36
  • 55
14
votes
12 answers

Notepad++ replacement

I've been using Notepad++ for a while now, but I noticed it doesn't have code snippets (I found the QuickText plug-in, but it doesn't work anymore), so I'd like to switch editor and my requirements would be: Fast startup. Code snippets. Ability…
ManBehindTheCurtain
  • 2,498
  • 4
  • 24
  • 33
14
votes
1 answer

Expanding multi-line snippet adds extra line at the bottom

Is there any way to prevent the addition of an extra line below a multi-line snippet in VB.NET? (hit tab key to expand snippet...) I've double checked that the snippet itself does not have an extra line at the end. Also, this seems to be…
rory.ap
  • 34,009
  • 10
  • 83
  • 174