Zed JavaScript Snippets
A comprehensive collection of JavaScript snippets for Zed editor, designed to accelerate JavaScript development with intelligent autocomplete and placeholder support.
✨ Features
- 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
📦 Installation
Via Zed Extensions (Recommended)
- Open Zed editor
- Press
Cmd/Ctrl + Shift + Pto open the command palette - Type "extensions" and select "zed: extensions"
- Search for "JavaScript Snippets"
- Click "Install"
Manual Installation
Clone this repository:
git clone https://github.com/seekode/zed-js-snippetsCopy the extension to your Zed extensions directory:
- macOS:
~/.config/zed/extensions/ - Linux:
~/.config/zed/extensions/ - Windows:
%APPDATA%\Zed\extensions\
- macOS:
Restart Zed
🚀 Usage
Simply start typing any JavaScript keyword or use the prefix shortcuts. The snippets will appear in the autocomplete menu.
Quick Start Examples
| 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 |
📋 Available Snippets
Console Methods
log- Console logwarn- Console warnerror- Console errortable- Console tabletime- Console time/timeEnd
Functions
function- Function declarationaf- Arrow functionafi- Arrow function (implicit return)asf- Async functionaaf- Async arrow functionfn- Anonymous functioniife- Immediately Invoked Function Expressioniiafe- Async IIFE
Loops & Iteration
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
Conditionals
if- If statementife- If...else statementei- Else if statementter- Ternary operatorswitch- Switch statement
Error Handling
tc- Try...catch blocktcf- Try...catch...finallyther- Throw errorcerr- Custom error class
Promises & Async
promise- New Promisethenc- Promise then/catchawait- Await expressionawaitc- Await with try/catch
Classes
class- Class declarationclm- Class with methodclx- Class extendsget- Getter methodset- Setter methodsm- Static method
Modules
imp- Import defaultimn- Import namedima- Import all (as)imd- Dynamic importexp- Export defaultexn- Export namedexa- Export allexf- Export functionexc- Export const
Variables & Destructuring
const- Const declarationlet- Let declarationvar- Var declarationdsta- Array destructuringdsto- Object destructuringspa- Spread arrayspo- Spread objectrp- Rest parameters
Objects
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()
Arrays & Collections
array- Array literalafrom- Array.from()aof- Array.of()nset- New Setnmap- New Mapnws- New WeakSetnwm- New WeakMap
Strings
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
Timers
sto- setTimeoutsi- setIntervalcto- clearTimeoutci- clearInterval
Fetch & JSON
fetch- Fetch APIfeta- Fetch async/awaitfetp- Fetch POST requestjsp- JSON.parse()jss- JSON.stringify()jssp- JSON.stringify() (pretty)
DOM Manipulation
qs- querySelectorqsa- querySelectorAllgid- getElementByIdgcl- getElementsByClassNamegt- getElementsByTagNamecel- createElementael- addEventListenerrel- removeEventListenerdomr- DOMContentLoadedwl- Window load eventraf- requestAnimationFrame
Storage
lss- localStorage.setItem()lsg- localStorage.getItem()lsr- localStorage.removeItem()lsc- localStorage.clear()sss- sessionStorage.setItem()ssg- sessionStorage.getItem()
Advanced Features
gen- Generator functionagen- Async generatorproxy- Proxy objectrget- Reflect.get()sym- Symbolsymf- Symbol.for()
Regular Expressions
re- RegExp patternret- RegExp testmatch- String match
Math & Date
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
Operators
tof- typeof checkiof- instanceof checknc- Nullish coalescing (??)oc- Optional chaining (?.)
Documentation
cmt- Comment blockjsdoc- JSDoc functionus- Use strict
🎯 Smart Placeholders
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 parametersThe $0 placeholder indicates the final cursor position.
🛠️ Customization
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", "}"]
}
}🤝 Contributing
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.
Development Setup
- Fork the repository
- Clone your fork
- Make your changes
- Test in Zed
- Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Zed Team for creating an amazing editor
- JavaScript community and ECMAScript contributors
- Community feedback and contributions
📞 Support
- Issues: GitHub Issues
- Zed Community: Zed Discord
- Documentation: Zed Documentation
Happy coding with Zed! 🚀