Sublime Text 3疑似Bug:Ctrl+z与Ctrl+s功能异常求助
Hey there! Sounds like your keybindings are getting overridden by that "Emacs Tabstop to Spaces" feature, which is why your Ctrl+Z and Ctrl+S are acting weird instead of doing undo/save like you expect. Let's walk through how to fix this step by step:
1. Fix Your User Keybinding Syntax First
First off, there's a tiny syntax issue in your current config that might be stopping it from working properly. Sublime Text expects keybindings to be wrapped in an array, and key names shouldn't have spaces. Update your user keybindings file (open via Preferences > Key Bindings) to look like this:
[ { "keys": ["ctrl+z"], "command": "undo" }, { "keys": ["ctrl+s"], "command": "save" } ]
This ensures Sublime reads your bindings correctly and prioritizes them over default or plugin-based ones.
2. Track Down the Culprit Plugin/Feature
The "Undo Emacs Tabstop to Spaces" label in your edit menu points directly to what's hijacking your keys. This is almost certainly coming from:
- An Emacs emulation plugin (like
Emacs Pro Essentialsor similar) that's overriding standard shortcuts - A third-party tab/space formatting tool that accidentally mapped to these keys
To test this:
- Open
Preferences > Package Control > Disable Packageand turn off any Emacs-related packages first. - Restart Sublime and check if Ctrl+Z/Ctrl+S work as expected. If they do, you’ve found the culprit—you can either keep the plugin disabled, or dig into its settings to re-map its tab-related shortcuts to other keys.
3. Explicitly Override the Hijacked Command
If disabling plugins isn’t an option, you can force Sublime to prioritize your desired commands by adding context to your keybindings. Update your user keybindings array to this:
[ { "keys": ["ctrl+z"], "command": "undo", "context": [ { "key": "setting.command_mode", "operator": "equal", "operand": false } ] }, { "keys": ["ctrl+s"], "command": "save" } ]
The context line ensures this binding only applies when you’re in normal edit mode (not command mode, which some Emacs plugins use), making it more reliable.
4. Double-Check Default Bindings (Optional)
To confirm the issue, you can peek at the default keybindings: go to Preferences > Key Bindings - Default and search for "undo_emacs_tabstop_to_spaces". If you find it mapped to Ctrl+Z, you don’t need to edit this read-only file—just know your user bindings need to explicitly override it.
After making these changes, restart Sublime Text and your Ctrl+Z/Ctrl+S should go back to their normal undo/save behavior.
内容的提问来源于stack exchange,提问作者TaGy

