SyncWrite — VSCode Extension
Seamlessly synchronize JSON values across multiple files for consistent configuration management!
✨ Features
- JSON File Synchronization: Sync JSON values across multiple files on save automatically. 🔄
- Intelligent Merging: Preserve existing structure while updating shared values. 🧠
- Opened Files Only: Works exclusively with JSON files that are currently open in VS Code. 📁
- Smart Value Matching: Only syncs values that exist in both source and target files. 🎯
- Save-Triggered Sync: Synchronization happens automatically when you save a JSON file. ⚡
- Visual Indicators: Status bar shows when sync is active. 📊
- Command Palette Integration: Easy enable/disable controls. 🎛️
- Error Handling: Silently skips files with invalid JSON content. 🛡️
📦 Installation
- Open Visual Studio Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side.
- Search for
SyncWrite
and click Install.
🛠️ Usage
- Once installed, open multiple JSON files in VS Code.
- Enable SyncWrite using the Command Palette (
Ctrl+Shift+P
/ Cmd+Shift+P
) and type "SyncWrite: Enable Sync".
- Edit values in any JSON file and save (
Ctrl+S
/ Cmd+S
).
- See the magic happens! Values automatically sync to other open JSON files that have matching keys. 🪄
⚙️ Configuration
You can customize the extension settings by adding the following configuration in your settings.json
:
{
"syncWrite.enabled": false // Enable/disable synchronization (default: false)
}
📋 Examples
JSON Value Synchronization
// File 1: config.json
{
"name": "My App",
"version": "1.0.0",
"apiUrl": "https://api.example.com"
}
// File 2: package.json
{
"name": "My App",
"version": "1.0.0",
"description": "My application"
}
// When you change "name" or "version" in one file and save, it updates in the other
Nested JSON Synchronization
// File 1: settings.json
{
"database": {
"host": "localhost",
"port": 5432
}
}
// File 2: config.json
{
"database": {
"host": "localhost",
"port": 5432,
"name": "myapp"
}
}
// Changing "host" or "port" in one file syncs to the other
🔧 How It Works
- Save Detection: When you save a JSON file, SyncWrite detects the change
- Target Selection: Finds all other open JSON files
- Value Matching: Identifies keys that exist in both source and target files
- Smart Sync: Updates only matching values, preserving the target file's structure
- Error Handling: Skips files with invalid JSON or missing keys
🛠️ Development
Prerequisites
- Node.js
- VS Code
- TypeScript
Setup
npm install
npm run compile
Testing
- Open this project in VS Code
- Press
F5
to launch Extension Development Host
- Open multiple JSON files with similar content
- Enable SyncWrite and test value synchronization
Building
npm run compile
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.