如何为Eclipse添加类Sublime Text的快捷键映射?
Absolutely doable—and it’s the perfect way to combine Sublime Text’s fast, smooth operation with the shortcut habits you’ve built in Eclipse. No need to choose between your preferred workflow and a better coding editor—here’s how to set it up:
Manual Keybinding Setup (Full Control)
If you want to pick and choose exactly which shortcuts to map, follow these steps:
- Open Sublime Text, then go to
Preferences > Key Bindingsfrom the top menu. This splits your screen into two files: the default system keybindings (left, don’t edit this!) and your custom user keybindings (right, this is where you’ll add changes). - Paste in the Eclipse-style bindings you need. For example, here are some common ones you might want:
[ // Duplicate line (Eclipse: Ctrl+Alt+Up/Down) { "keys": ["ctrl+alt+down"], "command": "duplicate_line" }, { "keys": ["ctrl+alt+up"], "command": "duplicate_line" }, // Delete entire line (Eclipse: Ctrl+D) { "keys": ["ctrl+d"], "command": "delete_line" }, // Find in files (Eclipse: Ctrl+H) { "keys": ["ctrl+h"], "command": "show_panel", "args": {"panel": "find_in_files"} }, // Quick jump to matching bracket (Eclipse: Ctrl+Shift+P) { "keys": ["ctrl+shift+p"], "command": "find_matching_bracket" }, // Open quick outline (similar to Eclipse's Ctrl+O) { "keys": ["ctrl+o"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} } ] - Save the user keybindings file, and the shortcuts will take effect immediately. You can add or remove bindings based on the Eclipse shortcuts you use most often.
Use a Plugin for One-Click Setup (Recommended)
If you don’t want to map shortcuts one by one, there’s a ready-made plugin that handles most of the work:
- Open Package Control by pressing
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac). - Type
Install Packageand hit Enter. - Search for Eclipse Keymap and install it.
This plugin automatically maps nearly all of Eclipse’s core shortcuts to Sublime Text, so you can jump back into your familiar workflow right away without any manual setup.
Tweak as Needed
Even with the plugin, you might find a few shortcuts that don’t behave exactly like you expect. Just head back to Preferences > Key Bindings and add custom bindings to override the plugin’s settings—your custom bindings will always take priority over the plugin’s.
This setup lets you keep enjoying Sublime Text’s lightweight, responsive experience while sticking to the shortcut muscle memory you’ve built with Eclipse. No more fighting with Eclipse’s clunkiness, and no need to relearn a whole new set of commands!
内容的提问来源于stack exchange,提问作者chinloyal

