A comprehensive collection of JavaScript snippets for Zed editor, designed to accelerate JavaScript development with intelligent autocomplete and placeholder support.
- Complete ES6+ Coverage: 150+ snippets covering modern JavaScript features
- Smart Placeholders: Tab-navigable placeholders for efficient coding
- Async/Await Support: Modern asynchronous programming patterns
- Array Methods: Complete coverage of map, filter, reduce, and more
- Class Syntax: ES6 classes with methods, getters, and setters
- Module System: Import/export statements for modern JavaScript
- Open Zed editor
- Press
Cmd/Ctrl + Shift + P
to open the command palette - Type "extensions" and select "zed: extensions"
- Search for "JavaScript Snippets"
- Click "Install"
-
Clone this repository:
git clone https://github.com/seekode/zed-js-snippets
-
Copy the extension to your Zed extensions directory:
- macOS:
~/.config/zed/extensions/
- Linux:
~/.config/zed/extensions/
- Windows:
%APPDATA%\Zed\extensions\
- macOS:
-
Restart Zed
Simply start typing any JavaScript keyword or use the prefix shortcuts. The snippets will appear in the autocomplete menu.
Prefix | Output | Description |
---|---|---|
log |
console.log($0) |
Console log statement |
af |
const name = (params) => {} |
Arrow function |
asf |
async function name() {} |
Async function |
for |
for (let i = 0; i < array.length; i++) |
For loop |
fetch |
fetch(url).then().catch() |
Fetch API call |
log
- Console logwarn
- Console warnerror
- Console errortable
- Console tabletime
- Console time/timeEnd
function
- Function declarationaf
- Arrow functionafi
- Arrow function (implicit return)asf
- Async functionaaf
- Async arrow functionfn
- Anonymous functioniife
- Immediately Invoked Function Expressioniiafe
- Async IIFE
for
- For loopforof
- For...of loopforin
- For...in loopwhile
- While loopdowhile
- Do...while loopfre
- Array forEachmap
- Array mapfilter
- Array filterreduce
- Array reducefind
- Array findfindi
- Array findIndexsome
- Array someevery
- Array every
if
- If statementife
- If...else statementei
- Else if statementter
- Ternary operatorswitch
- Switch statement
tc
- Try...catch blocktcf
- Try...catch...finallyther
- Throw errorcerr
- Custom error class
promise
- New Promisethenc
- Promise then/catchawait
- Await expressionawaitc
- Await with try/catch
class
- Class declarationclm
- Class with methodclx
- Class extendsget
- Getter methodset
- Setter methodsm
- Static method
imp
- Import defaultimn
- Import namedima
- Import all (as)imd
- Dynamic importexp
- Export defaultexn
- Export namedexa
- Export allexf
- Export functionexc
- Export const
const
- Const declarationlet
- Let declarationvar
- Var declarationdsta
- Array destructuringdsto
- Object destructuringspa
- Spread arrayspo
- Spread objectrp
- Rest parameters
obj
- Object literalom
- Object with methodos
- Object shorthandoc
- Object computed propertyok
- Object.keys()ov
- Object.values()oe
- Object.entries()oa
- Object.assign()ofr
- Object.freeze()oseal
- Object.seal()ocr
- Object.create()
array
- Array literalafrom
- Array.from()aof
- Array.of()nset
- New Setnmap
- New Mapnws
- New WeakSetnwm
- New WeakMap
tl
- Template literaltt
- Tagged templatematch
- String matchreplace
- String replacesplit
- String splittrim
- String trimincludes
- String includesstartswith
- String startsWithendswith
- String endsWithpadstart
- String padStartpadend
- String padEndrepeat
- String repeat
sto
- setTimeoutsi
- setIntervalcto
- clearTimeoutci
- clearInterval
fetch
- Fetch APIfeta
- Fetch async/awaitfetp
- Fetch POST requestjsp
- JSON.parse()jss
- JSON.stringify()jssp
- JSON.stringify() (pretty)
qs
- querySelectorqsa
- querySelectorAllgid
- getElementByIdgcl
- getElementsByClassNamegt
- getElementsByTagNamecel
- createElementael
- addEventListenerrel
- removeEventListenerdomr
- DOMContentLoadedwl
- Window load eventraf
- requestAnimationFrame
lss
- localStorage.setItem()lsg
- localStorage.getItem()lsr
- localStorage.removeItem()lsc
- localStorage.clear()sss
- sessionStorage.setItem()ssg
- sessionStorage.getItem()
gen
- Generator functionagen
- Async generatorproxy
- Proxy objectrget
- Reflect.get()sym
- Symbolsymf
- Symbol.for()
re
- RegExp patternret
- RegExp testmatch
- String match
mra
- Math.random()mfl
- Math.floor()mce
- Math.ceil()mro
- Math.round()mmax
- Math.max()mmin
- Math.min()dnow
- Date.now()ndate
- New Date()diso
- ISO date string
tof
- typeof checkiof
- instanceof checknc
- Nullish coalescing (??)oc
- Optional chaining (?.)
cmt
- Comment blockjsdoc
- JSDoc functionus
- Use strict
Snippets use numbered placeholders ($1
, $2
, etc.) that you can tab through:
// Typing 'af' + Tab
const functionName = (params) => {};
// Tab to functionName, type name, Tab to params, type parameters
The $0
placeholder indicates the final cursor position.
You can modify snippets by editing the snippets/javascript.json
file. Each snippet follows this structure:
{
"Snippet Name": {
"prefix": "trigger-text",
"body": ["const ${1:name} = (${2:params}) => {", "\t$0", "}"]
}
}
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Clone your fork
- Make your changes
- Test in Zed
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Zed Team for creating an amazing editor
- JavaScript community and ECMAScript contributors
- Community feedback and contributions
- Issues: GitHub Issues
- Zed Community: Zed Discord
- Documentation: Zed Documentation
Happy coding with Zed! π