VS Code Setup
VS Code Setup for MirthSync
Section titled “VS Code Setup for MirthSync”Visual Studio Code is an excellent choice for working with MirthSync projects. This guide helps you optimize VS Code for editing Mirth Connect channels, code templates, and configurations.
Recommended Extensions
Section titled “Recommended Extensions”Install these extensions to enhance your MirthSync development experience:
Essential Extensions
Section titled “Essential Extensions”XML Tools
- Extension ID:
DotJoshJohnson.xml - Provides: XML formatting, validation, and tree view
- Use: Format channel.xml files, validate XML structure
JavaScript (ES6) Code Snippets
- Extension ID:
xabikos.JavaScriptSnippets - Provides: JavaScript code snippets and shortcuts
- Use: Quick insertion of common JavaScript patterns in transformers
GitLens
- Extension ID:
eamodio.gitlens - Provides: Enhanced Git capabilities and history
- Use: View commit history, blame annotations, compare changes
Optional but Helpful
Section titled “Optional but Helpful”Prettier
- Extension ID:
esbenp.prettier-vscode - Provides: Code formatting
- Use: Auto-format JavaScript code in transformers
Error Lens
- Extension ID:
usernamehw.errorlens - Provides: Inline error highlighting
- Use: See XML and JavaScript errors immediately
Path Intellisense
- Extension ID:
christian-kohler.path-intellisense - Provides: Autocomplete for file paths
- Use: Quick navigation to related files
VS Code Settings
Section titled “VS Code Settings”Create or update .vscode/settings.json in your MirthSync project:
{ // File associations "files.associations": { "channel.xml": "xml", "*.xml": "xml" },
// Editor settings "editor.formatOnSave": true, "editor.tabSize": 2, "editor.insertSpaces": true,
// XML formatting "xml.format.enabled": true, "xml.format.splitAttributes": false,
// JavaScript settings "javascript.format.enable": true, "javascript.suggest.autoImports": false,
// File exclusions (optional) "files.exclude": { "**/.git": true, "**/.DS_Store": true },
// Search exclusions "search.exclude": { "**/node_modules": true, "**/.git": true }}Workspace Configuration
Section titled “Workspace Configuration”For team consistency, commit .vscode/settings.json to your repository. This ensures all team members use the same editor settings.
Useful Keyboard Shortcuts
Section titled “Useful Keyboard Shortcuts”Navigation
Section titled “Navigation”Ctrl+P(Windows/Linux) orCmd+P(Mac) - Quick file openCtrl+Shift+F- Search across all filesCtrl+B- Toggle sidebarCtrl+` - Toggle terminal
Editing
Section titled “Editing”Alt+Up/Down- Move line up/downShift+Alt+Up/Down- Copy line up/downCtrl+D- Select next occurrenceCtrl+Shift+L- Select all occurrencesCtrl+/- Toggle comment
Ctrl+Shift+G- Open Source ControlCtrl+Enter- Commit staged changesCtrl+Shift+Pthen “Git: View History” - View commit history
Workflow Tips
Section titled “Workflow Tips”1. Use the Explorer
Section titled “1. Use the Explorer”The VS Code file explorer makes it easy to navigate your MirthSync project structure:
- Expand folders to see channels and code templates
- Right-click files for context menu options
- Use
Ctrl+Clickto open files in new tabs
2. Search and Replace
Section titled “2. Search and Replace”VS Code’s search is powerful for bulk changes:
Ctrl+Shift+Fopens search across all files- Use regex patterns for complex searches
- Preview changes before replacing
3. Split View
Section titled “3. Split View”Compare channels or view multiple files:
- Right-click a file tab > “Split Right”
- Drag tabs to create custom layouts
- Useful for comparing channel configurations
4. Integrated Terminal
Section titled “4. Integrated Terminal”VS Code’s integrated terminal lets you run MirthSync commands:
Ctrl+`opens terminal- Run
./mirthsync.sh pull,./mirthsync.sh push, etc. - See output directly in the editor
5. Git Integration
Section titled “5. Git Integration”VS Code has excellent Git support:
- View file changes with green/red indicators
- Stage files with
+button - Write commit messages in the editor
- View diff side-by-side
Example Workflow
Section titled “Example Workflow”-
Open Project
Terminal window code /path/to/mirthsync-project -
Pull Latest
- Open terminal:
Ctrl+` - Run:
./mirthsync.sh pull -s https://server:8443/api -u admin -t .
- Open terminal:
-
Edit Files
- Navigate to channel in Explorer
- Open
channel.xml - Edit JavaScript transformer
- Save:
Ctrl+S
-
Review Changes
- Click Source Control icon (or
Ctrl+Shift+G) - Review diff for changed files
- Stage files: Click
+next to files
- Click Source Control icon (or
-
Commit
- Write commit message
- Press
Ctrl+Enterto commit
-
Push to Mirth Connect
- Open terminal
- Run:
./mirthsync.sh push -s https://server:8443/api -u admin -t .
Troubleshooting
Section titled “Troubleshooting”XML Not Formatting
Section titled “XML Not Formatting”If XML files aren’t formatting:
- Install “XML Tools” extension
- Check
xml.format.enabledin settings - Right-click file > “Format Document”
JavaScript Not Highlighting
Section titled “JavaScript Not Highlighting”If JavaScript in XML transformers isn’t highlighted:
- Ensure file is recognized as XML
- JavaScript within XML should highlight automatically
- Check
files.associationsin settings
Git Not Showing Changes
Section titled “Git Not Showing Changes”If Git panel doesn’t show changes:
- Ensure folder is a Git repository (
./mirthsync.sh -t . git init) - Check
.gitignoreisn’t excluding files - Reload window:
Ctrl+Shift+P> “Reload Window”