Sublime Text 3配置全备份方案?用于灾备、新机迁移等场景
Hey Michael, great question—this is exactly the kind of setup that saves you hours of headache when switching machines or recovering from a crash. The good news is that all of Sublime's customizations (packages, settings, snippets, shortcuts, etc.) live in a single directory, so backing everything up is straightforward once you know where to look.
Step 1: Locate Your Sublime Config Directory
First, find the root folder where Sublime stores all its user data. The path varies by OS:
- Windows:
%APPDATA%\Sublime Text 3 - macOS:
~/Library/Application Support/Sublime Text 3 - Linux:
~/.config/sublime-text-3
You can also open this folder directly from Sublime: go to Preferences > Browse Packages, then navigate up one level (the Packages folder is inside the config directory we need).
Step 2: Back Up the Entire Directory
There are two reliable ways to back this up, depending on your preference:
Option 1: Manual Cloud/External Backup
- Close Sublime Text first (to avoid file locking issues)
- Copy the entire config directory to a cloud storage service (Dropbox, OneDrive, Google Drive) or an external drive
- This gives you a full snapshot of every customization you’ve made
Option 2: Git Version Control (Recommended)
For more control (and the ability to track changes to your config over time), use Git to version the directory:
- Initialize a Git repo inside the config directory:
cd /path/to/your/sublime-config-folder git init - Create a
.gitignorefile to exclude temporary files that don’t need backing up:Cache/ Local/ - Commit all your files:
git add . git commit -m "Initial Sublime config backup" - Push the repo to a remote Git host for off-site storage
Step 3: Restore/Migrate to a New Machine
For Manual Backups
- Install Sublime Text 3 on the new machine, then close it immediately
- Replace the default config directory (from Step 1) with your backed-up copy
- Launch Sublime: it will load all your packages, settings, snippets, and themes automatically. Package Control will even check for any missing packages and install them if needed.
For Git Backups
- Install Sublime Text 3 on the new machine, close it
- Delete the default config directory (or rename it as a backup)
- Clone your Git repo into the config directory path:
git clone https://your-repo-url.git /path/to/sublime-config-folder - Launch Sublime—everything will be exactly as you left it.
Bonus: Why This Works Better Than Package-Only Installation
The method you found for bulk-installing packages is great for quickly setting up packages, but it misses all the critical customizations that make your Sublime setup yours:
- Your personalized
Preferences.sublime-settings(font sizes, tab widths, color schemes) - Custom keyboard shortcuts (
Default (OS).sublime-keymap) - User-created code snippets (all
.sublime-snippetfiles in theUserfolder) - Theme-specific settings, package customizations (like LSP configurations), and even your open project history
By backing up the entire config directory, you capture every last detail of your setup.
Give this a try—once you have this system in place, moving to a new machine or recovering from a crash will be a total breeze. Let me know if you run into any small issues getting it set up!
内容的提问来源于stack exchange,提问作者Michael D




