Skip to content

Commit 930c33d

Browse files
Create community_snippets.md for user created snippets (#1246)
* Create community_snippets.md * addsnip-and-table
1 parent a13bc67 commit 930c33d

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

docs/community_snippets.md

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Awesome VSCode Snippets for PowerShell
2+
3+
> A curated list of awesome vscode snippets for PowerShell.
4+
5+
*Inspired by the [awesome](https://github.com/sindresorhus/awesome) lists, focusing on PowerShell snippets in VSCode*
6+
7+
[![Awesome](https://awesome.re/badge.svg)](https://awesome.re)
8+
9+
## What are snippets
10+
11+
Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements. Check out the [VSCode documentation on snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets). It provides an overview and instructions on how to author snippets. It's really simple - just a little bit of JSON.
12+
13+
_To contribute, check out our [guide here](#contributing)._
14+
15+
## Table of contents
16+
17+
| Table of Contents |
18+
|:-----------------:|
19+
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject by @brettmillerb_ |
20+
21+
## Snippets
22+
23+
### PSCustomObject
24+
25+
A simple PSCustomObject by @brettmillerb. It has 4 properties that you can tab through to quickly fill in.
26+
27+
#### Snippet
28+
29+
```json
30+
"PSCustomObject": {
31+
"prefix": "PSCustomObject",
32+
"body": [
33+
"[PSCustomObject]@{\r",
34+
"\t${item1} = ${Property1}\r",
35+
"\t${item2} = ${Property2}\r",
36+
"\t${item3} = ${Property3}\r",
37+
"\t${item4} = ${Property4}\r",
38+
"}"
39+
],
40+
"description": "Creates a PSCustomObject"
41+
}
42+
```
43+
44+
## Contributing
45+
46+
If you'd like to add a snippet to this list, [open a pull request](https://opensource.guide/how-to-contribute/#opening-a-pull-request) with the following changes:
47+
48+
### Table of context
49+
50+
You need to add an item to the table of context. The addition should follow the *alpha ordering* of the list.
51+
The ToC item template looks like this:
52+
53+
```md
54+
| [Name of snippet](link to header of your snippet): _some short description_ |
55+
```
56+
57+
An example looks like this (NOTE: all lowercase link):
58+
59+
```md
60+
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject_ |
61+
```
62+
63+
which will show up in the ToC like this:
64+
65+
| Table of Contents |
66+
|:-----------------:|
67+
| [PSCustomObject](#pscustomobject): _A simple PSCustomObject_ |
68+
69+
### Body
70+
71+
You need to also add an item to the body in alpha order. The body item template looks like this:
72+
73+
### Name of snippet
74+
75+
Enter your description here. It can be the same as the ToC or a longer version.
76+
77+
#### Snippet
78+
79+
```json
80+
{
81+
"Put your":"snippet here",
82+
"indent it":"properly"
83+
}
84+
```
85+
86+
An example looks like this:
87+
88+
### PSCustomObject
89+
90+
A simple PSCustomObject.
91+
92+
#### Snippet
93+
94+
```json
95+
"PSCustomObject": {
96+
"prefix": "PSCustomObject",
97+
"body": [
98+
"[PSCustomObject]@{",
99+
"\t${1:Name} = ${2:Value}",
100+
"}"
101+
],
102+
"description": "Creates a PSCustomObject"
103+
}
104+
```
105+
106+
which will show up in the body like this:
107+
108+
### PSCustomObject
109+
110+
A simple PSCustomObject. Note, this snippet ships with the PowerShell extension.
111+
112+
#### Snippet
113+
114+
```json
115+
"PSCustomObject": {
116+
"prefix": "PSCustomObject",
117+
"body": [
118+
"[PSCustomObject]@{",
119+
"\t${1:Name} = ${2:Value}",
120+
"}"
121+
],
122+
"description": "Creates a PSCustomObject"
123+
}
124+
```

0 commit comments

Comments
 (0)