Created
October 15, 2012 04:03
-
-
Save mcdonc/3890756 to your computer and use it in GitHub Desktop.
Chris' Sublime Text 2 Emacsey keybindings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
// Chris' "emacs refugee" Sublime Text 2 key mappings. Depends on | |
// sublemacspro and Wrap Plus packages, plus a custom pdb.set_trace snippet | |
// named set_trace.sublime-snippet. It outs me as someone who uses cursor | |
// keys; try not to judge. | |
// "bol"/"eol" goes to a logical begin/end of line; we want it to go to true | |
// line begin/end, so we use hardbol/hardeol instead for ctrl-a and ctrl-e | |
{ "keys": ["ctrl+a"], "command": "move_to", | |
"args": {"to": "hardbol", "extend": false} }, | |
{ "keys": ["ctrl+e"], "command": "move_to", | |
"args": {"to": "hardeol", "extend": false} }, | |
// Use Wrap Plus version of wrap_lines: it does a better job of wrapping | |
// Python docstrings than either sublemacs "sbp_wrap_paragraph" or sublime's | |
// "wrap_lines" | |
{ "keys": ["escape", "q"], "command": "wrap_lines_plus" }, | |
// I never used these keys in emacs, they might as well do something useful, | |
// remap them back to their original meanings | |
{ "keys": ["ctrl+v"], "command": "paste" }, | |
{ "keys": ["ctrl+o"], "command": "prompt_open_file" }, | |
{ "keys": ["ctrl+n"], "command": "new_file" }, | |
{ "keys": ["ctrl+p"], "command": "show_overlay", | |
"args": {"overlay": "goto", "show_files": true} }, | |
{ "keys": ["ctrl+d"], "command": "find_under_expand" }, | |
// Fix mark selection when using cursor keys instead of Emacs ctrl movement | |
{ "keys": ["right"], "command": "move", | |
"args": {"by": "characters", "forward": true, "extend": true}, | |
"context": | |
[ | |
{ "key":"sbp_emacs_has_mark", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["left"], "command": "move", | |
"args": {"by": "characters", "forward": false, "extend": true}, | |
"context": | |
[ | |
{ "key":"sbp_emacs_has_mark", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["ctrl+left"], "command": "move", | |
"args": {"by": "words", "forward": false, "extend": true}, | |
"context": | |
[ | |
{ "key":"sbp_emacs_has_mark", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["ctrl+right"], "command": "move", | |
"args": {"by": "word_ends", "forward": true, "extend": true}, | |
"context": | |
[ | |
{ "key":"sbp_emacs_has_mark", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["down"], "command": "move", | |
"args": {"by": "lines", "forward": true, "extend": true}, | |
"context": | |
[ | |
{ "key":"sbp_emacs_has_mark", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["up"], "command": "move", | |
"args": {"by": "lines", "forward": false, "extend": true}, | |
"context": | |
[ | |
{ "key":"sbp_emacs_has_mark", "operator": "equal", "operand": true } | |
] | |
}, | |
// Remap some useful sublime functionality lost to emacsy keybindings | |
{ "keys": ["ctrl+shift+r"], "command": "show_overlay", | |
"args": {"overlay": "goto", "text": "@"} }, | |
// Extra emacsy rebindings not covered by sublemacs | |
{ "keys": ["ctrl+x", "ctrl+d"], "command": "find_under_expand_skip" }, | |
{ "keys": ["ctrl+x", "d"], "command": "toggle_side_bar" }, | |
{ "keys": ["ctrl+x", "r", "k"], "command": "sbp_rectangle_delete" }, | |
{ "keys": ["ctrl+x", "r", "i"], "command": "sbp_rectangle_insert" }, | |
{ "keys": ["escape", "w"], "command": "sbp_kill_ring_save" }, | |
{ "keys": ["alt+y"], "command": "sbp_yank_choice" }, | |
{ "keys": ["ctrl+x", "u"], "command": "undo" }, | |
{ "keys": ["ctrl+c", ">"], "command": "indent" }, | |
{ "keys": ["ctrl+c", "<"], "command": "unindent" }, | |
{ "keys": ["ctrl+x", "5", "2"], "command": "new_window" }, | |
{ "keys": ["alt+g"], "command": "show_overlay", | |
"args": {"overlay": "goto", "text": ":"} }, | |
{ "keys": ["ctrl+9"], "command": "toggle_record_macro" }, | |
{ "keys": ["ctrl+0"], "command": "toggle_record_macro" }, | |
{ "keys": ["ctrl+x", "e"], "command": "run_macro" }, | |
// Allow toggling of word wrap | |
{ | |
"keys": ["alt+w"], | |
"command": "toggle_setting", | |
"args": | |
{ | |
"setting": "word_wrap" | |
} | |
}, | |
// Insert a pdb.set_trace() snippet when ctrl-t is pressed | |
{ | |
"keys": ["alt+t"], | |
"command": "insert_snippet", | |
"args": {"name": "Packages/User/Python/set_trace.sublime-snippet"} | |
}, | |
// Extend the circumstances under which ctrl-g behaves like escape, | |
// so when you hit ctrl-g over and over again like a true emacs monkey | |
// it actually does something | |
{ "keys": ["ctrl+g"], "command": "single_selection", "context": | |
[ | |
{ "key": "num_selections", "operator": "not_equal", "operand": 1 } | |
] | |
}, | |
{ "keys": ["ctrl+g"], "command": "clear_fields", "context": | |
[ | |
{ "key": "has_next_field", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["ctrl+g"], "command": "clear_fields", "context": | |
[ | |
{ "key": "has_prev_field", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["ctrl+g"], "command": "hide_panel", "args": {"cancel": true}, | |
"context": | |
[ | |
{ "key": "panel_visible", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["ctrl+g"], "command": "hide_overlay", "context": | |
[ | |
{ "key": "overlay_visible", "operator": "equal", "operand": true } | |
] | |
}, | |
{ "keys": ["ctrl+g"], "command": "hide_auto_complete", "context": | |
[ | |
{ "key": "auto_complete_visible", "operator": | |
"equal", "operand": true } | |
] | |
}, | |
// Tab can't autocomplete because it indents, and enter is annoying so use | |
// ctrl-enter to autocomplete | |
{ "keys": ["ctrl+enter"], "command": "commit_completion", "context": | |
[ | |
{ "key": "auto_complete_visible" }, | |
{ "key": "setting.auto_complete_commit_on_tab", "operand": true } | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment