Skip to content

Instantly share code, notes, and snippets.

@philippkeller
Created June 1, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippkeller/2c223a86c037d0217bf69fb044049fb9 to your computer and use it in GitHub Desktop.
Save philippkeller/2c223a86c037d0217bf69fb044049fb9 to your computer and use it in GitHub Desktop.
Make Sublime Keybindings on Windows same as on MacOS

When switching from Mac to Windows one thing which bugged me that Sublime didn't have the same keybindings. Especially: Emacs bindings such as Ctrl-a (beginning of line), ctrl-e (end of line), ctrl-f, ctrl-d, etc.

But also the copy-command on Alt+C (Alt is at the same position as the Apple key, so it corresponds to Apple-C), etc. I wanted to have the same.

So I copied over the keyboard shortcuts on Mac, added the Emacs-Keybindings and other Shortcuts which Mac provides, and removed the keybindings which are better left as is on Windows (e.g. those which don't include ctrl/alt)

Installation

Click Preferences->Keybindings. Paste the following file into the right editor pane, restart Sublime, Done.

/*
* these keybindings are taken over from OSX with:
* - super (aka mac key) replaced by alt (because alt is at the same position as the mac key)
* - keybindings with super+alt removed (except the layout keycombos like super-alt-2 to make two columns are replaced by alt-2, etc.)
* - ctrl-a, ctrl-e, etc which are provideed by Mac (aka Emacs keybindings) are added additionally
* - fixed some of the keybindings commands (e.g. on Windows it's prompt_open_file, on Mac it was prompt_open)
*/
[
/* "Emacs" keybindings which come on mac but not on windows, added "by hand" */
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol", "extend": false} },
{ "keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": true} },
{ "keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["ctrl+f"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["ctrl+b"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["ctrl+d"], "command": "right_delete" },
{ "keys": ["alt+left"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["alt+up"], "command": "move_to", "args": {"to": "bof", "extend": false} },
{ "keys": ["alt+down"], "command": "move_to", "args": {"to": "eof", "extend": false} },
{ "keys": ["alt+right"], "command": "move_to", "args": {"to": "eol", "extend": false} },
{ "keys": ["alt+shift+right"], "command": "move_to", "args": {"to": "eol", "extend": true} }, // select to end of line
{ "keys": ["alt+shift+left"], "command": "move_to", "args": {"to": "bof", "extend": false} }, // select to beginning of line
/* Rest is taken over from MacOS */
{ "keys": ["alt+shift+n"], "command": "new_window" },
{ "keys": ["alt+shift+w"], "command": "close_window" },
{ "keys": ["alt+o"], "command": "prompt_open_file" },
{ "keys": ["alt+shift+t"], "command": "reopen_last_file" },
{ "keys": ["alt+n"], "command": "new_file" },
{ "keys": ["alt+s"], "command": "save" },
{ "keys": ["alt+shift+s"], "command": "prompt_save_as" },
{ "keys": ["alt+w"], "command": "close" },
{ "keys": ["alt+k", "alt+b"], "command": "toggle_side_bar" },
{ "keys": ["alt+ctrl+f"], "command": "toggle_full_screen" },
{ "keys": ["alt+ctrl+shift+f"], "command": "toggle_distraction_free" },
{ "keys": ["alt+z"], "command": "undo" },
{ "keys": ["alt+shift+z"], "command": "redo" },
{ "keys": ["alt+y"], "command": "redo_or_repeat" },
{ "keys": ["alt+u"], "command": "soft_undo" },
{ "keys": ["alt+shift+u"], "command": "soft_redo" },
{ "keys": ["alt+x"], "command": "cut" },
{ "keys": ["alt+c"], "command": "copy" },
{ "keys": ["alt+v"], "command": "paste" },
{ "keys": ["alt+shift+v"], "command": "paste_and_indent" },
{ "keys": ["alt+k", "alt+v"], "command": "paste_from_history" },
{ "keys": ["ctrl+alt+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["ctrl+alt+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },
{ "keys": ["ctrl+alt+shift+left"], "command": "move", "args": {"by": "subwords", "forward": false, "extend": true} },
{ "keys": ["ctrl+alt+shift+right"], "command": "move", "args": {"by": "subword_ends", "forward": true, "extend": true} },
{ "keys": ["ctrl+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["ctrl+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },
{ "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "subwords", "forward": false, "extend": true} },
{ "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "subword_ends", "forward": true, "extend": true} },
{ "keys": ["ctrl+alt+up"], "command": "scroll_lines", "args": {"amount": 1.0} },
{ "keys": ["ctrl+alt+down"], "command": "scroll_lines", "args": {"amount": -1.0} },
{ "keys": ["ctrl+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+shift+down"], "command": "select_lines", "args": {"forward": true} },
{ "keys": ["alt+shift+["], "command": "prev_view" },
{ "keys": ["alt+shift+]"], "command": "next_view" },
{ "keys": ["ctrl+tab"], "command": "next_view_in_stack" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view_in_stack" },
{ "keys": ["alt+a"], "command": "select_all" },
{ "keys": ["alt+shift+l"], "command": "split_selection_into_lines" },
{ "keys": ["alt+]"], "command": "indent" },
{ "keys": ["alt+["], "command": "unindent" },
{ "keys": ["alt+l"], "command": "expand_selection", "args": {"to": "line"} },
{ "keys": ["alt+d"], "command": "find_under_expand" },
{ "keys": ["alt+k", "alt+d"], "command": "find_under_expand_skip" },
{ "keys": ["alt+shift+space"], "command": "expand_selection", "args": {"to": "scope"} },
{ "keys": ["ctrl+shift+m"], "command": "expand_selection", "args": {"to": "brackets"} },
{ "keys": ["ctrl+m"], "command": "move_to", "args": {"to": "brackets"} },
{ "keys": ["alt+shift+j"], "command": "expand_selection", "args": {"to": "indentation"} },
{ "keys": ["alt+shift+a"], "command": "expand_selection", "args": {"to": "tag"} },
{ "keys": ["ctrl+q"], "command": "toggle_record_macro" },
{ "keys": ["ctrl+shift+q"], "command": "run_macro" },
{ "keys": ["alt+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"} },
{ "keys": ["alt+shift+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line Before.sublime-macro"} },
{ "keys": ["alt+t"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["alt+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["alt+shift+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
// { "keys": ["alt+ctrl+p"], "command": "prompt_select_workspace" }, clashes with ö on us extended without dead keys
{ "keys": ["alt+r"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
{ "keys": ["ctrl+g"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["alt+shift+r"], "command": "goto_symbol_in_project" },
{ "keys": ["ctrl+minus"], "command": "jump_back" },
{ "keys": ["ctrl+shift+minus"], "command": "jump_forward" },
{ "keys": ["alt+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse": false} },
{ "keys": ["alt+shift+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse": true} },
{ "keys": ["alt+f"], "command": "show_panel", "args": {"panel": "find", "reverse": false} },
{ "keys": ["alt+g"], "command": "find_next" },
{ "keys": ["alt+shift+g"], "command": "find_prev" },
{ "keys": ["alt+e"], "command": "slurp_find_string" },
{ "keys": ["alt+shift+e"], "command": "slurp_replace_string" },
{ "keys": ["alt+shift+f"], "command": "show_panel", "args": {"panel": "find_in_files"} },
{ "keys": ["shift+f4"], "command": "prev_result" },
{ "keys": ["ctrl+backspace"], "command": "delete_word", "args": { "forward": false, "sub_words": true } },
{ "keys": ["ctrl+delete"], "command": "delete_word", "args": { "forward": true, "sub_words": true } },
{ "keys": ["alt+forward_slash"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["alt+j"], "command": "join_lines" },
{ "keys": ["alt+shift+d"], "command": "duplicate_line" },
{ "keys": ["ctrl+backquote"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
{ "keys": ["ctrl+shift+p"], "command": "show_scope_name" },
{ "keys": ["alt+b"], "command": "build" },
{ "keys": ["alt+shift+b"], "command": "build", "args": {"select": true} },
{ "keys": ["ctrl+c"], "command": "cancel_build" },
{ "keys": ["ctrl+t"], "command": "transpose" },
{ "keys": ["ctrl+f5"], "command": "sort_lines", "args": {"case_sensitive": true} },
{ "keys": ["ctrl+1"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["ctrl+2"], "command": "focus_group", "args": { "group": 1 } },
{ "keys": ["ctrl+3"], "command": "focus_group", "args": { "group": 2 } },
{ "keys": ["ctrl+4"], "command": "focus_group", "args": { "group": 3 } },
{ "keys": ["ctrl+5"], "command": "focus_group", "args": { "group": 4 } },
{ "keys": ["ctrl+6"], "command": "focus_group", "args": { "group": 5 } },
{ "keys": ["ctrl+7"], "command": "focus_group", "args": { "group": 6 } },
{ "keys": ["ctrl+8"], "command": "focus_group", "args": { "group": 7 } },
{ "keys": ["ctrl+9"], "command": "focus_group", "args": { "group": 8 } },
{ "keys": ["ctrl+shift+1"], "command": "move_to_group", "args": { "group": 0 } },
{ "keys": ["ctrl+shift+2"], "command": "move_to_group", "args": { "group": 1 } },
{ "keys": ["ctrl+shift+3"], "command": "move_to_group", "args": { "group": 2 } },
{ "keys": ["ctrl+shift+4"], "command": "move_to_group", "args": { "group": 3 } },
{ "keys": ["ctrl+shift+5"], "command": "move_to_group", "args": { "group": 4 } },
{ "keys": ["ctrl+shift+6"], "command": "move_to_group", "args": { "group": 5 } },
{ "keys": ["ctrl+shift+7"], "command": "move_to_group", "args": { "group": 6 } },
{ "keys": ["ctrl+shift+8"], "command": "move_to_group", "args": { "group": 7 } },
{ "keys": ["ctrl+shift+9"], "command": "move_to_group", "args": { "group": 8 } },
{ "keys": ["ctrl+0"], "command": "focus_side_bar" },
{ "keys": ["alt+k", "alt+up"], "command": "new_pane" },
{ "keys": ["alt+k", "alt+shift+up"], "command": "new_pane", "args": {"move": false} },
{ "keys": ["alt+k", "alt+down"], "command": "close_pane" },
{ "keys": ["alt+k", "alt+left"], "command": "focus_neighboring_group", "args": {"forward": false} },
{ "keys": ["alt+k", "alt+right"], "command": "focus_neighboring_group" },
{ "keys": ["alt+k", "alt+shift+left"], "command": "move_to_neighboring_group", "args": {"forward": false} },
{ "keys": ["alt+k", "alt+shift+right"], "command": "move_to_neighboring_group" },
{ "keys": ["alt+1"], "command": "select_by_index", "args": { "index": 0 } },
{ "keys": ["alt+2"], "command": "select_by_index", "args": { "index": 1 } },
{ "keys": ["alt+3"], "command": "select_by_index", "args": { "index": 2 } },
{ "keys": ["alt+4"], "command": "select_by_index", "args": { "index": 3 } },
{ "keys": ["alt+5"], "command": "select_by_index", "args": { "index": 4 } },
{ "keys": ["alt+6"], "command": "select_by_index", "args": { "index": 5 } },
{ "keys": ["alt+7"], "command": "select_by_index", "args": { "index": 6 } },
{ "keys": ["alt+8"], "command": "select_by_index", "args": { "index": 7 } },
{ "keys": ["alt+9"], "command": "select_by_index", "args": { "index": 8 } },
{ "keys": ["alt+0"], "command": "select_by_index", "args": { "index": 9 } },
{ "keys": ["alt+k", "alt+u"], "command": "upper_case" },
{ "keys": ["alt+k", "alt+l"], "command": "lower_case" },
{ "keys": ["alt+k", "alt+space"], "command": "set_mark" },
{ "keys": ["alt+k", "alt+a"], "command": "select_to_mark" },
{ "keys": ["alt+k", "alt+w"], "command": "delete_to_mark" },
{ "keys": ["alt+k", "alt+x"], "command": "swap_with_mark" },
{ "keys": ["alt+k", "alt+g"], "command": "clear_bookmarks", "args": {"name": "mark"} },
{ "keys": ["alt+equals"], "command": "increase_font_size" },
{ "keys": ["alt+plus"], "command": "increase_font_size" },
{ "keys": ["alt+minus"], "command": "decrease_font_size" },
{ "keys": ["ctrl+shift+w"], "command": "insert_snippet", "args": { "name": "Packages/XML/Snippets/long-tag.sublime-snippet" } },
{ "keys": ["ctrl+shift+k"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["alt+k", "alt+1"], "command": "fold_by_level", "args": {"level": 1} },
{ "keys": ["alt+k", "alt+2"], "command": "fold_by_level", "args": {"level": 2} },
{ "keys": ["alt+k", "alt+3"], "command": "fold_by_level", "args": {"level": 3} },
{ "keys": ["alt+k", "alt+4"], "command": "fold_by_level", "args": {"level": 4} },
{ "keys": ["alt+k", "alt+5"], "command": "fold_by_level", "args": {"level": 5} },
{ "keys": ["alt+k", "alt+6"], "command": "fold_by_level", "args": {"level": 6} },
{ "keys": ["alt+k", "alt+7"], "command": "fold_by_level", "args": {"level": 7} },
{ "keys": ["alt+k", "alt+8"], "command": "fold_by_level", "args": {"level": 8} },
{ "keys": ["alt+k", "alt+9"], "command": "fold_by_level", "args": {"level": 9} },
{ "keys": ["alt+k", "alt+0"], "command": "unfold_all" },
{ "keys": ["alt+k", "alt+j"], "command": "unfold_all" },
{ "keys": ["alt+k", "alt+t"], "command": "fold_tag_attributes" },
{ "keys": ["alt+,"], "command": "edit_settings", "args":
{
"base_file": "${packages}/Default/Preferences.sublime-settings",
"default": "// Settings in here override those in \"Default/Preferences.sublime-settings\",\n// and are overridden in turn by syntax-specific settings.\n{\n\t$0\n}\n"
}
},
{ "keys": ["alt+k", "alt+y"], "command": "yank" },
{ "keys": ["alt+k", "alt+k"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete to Hard EOL.sublime-macro"} },
{ "keys": ["alt+k", "alt+backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete to Hard BOL.sublime-macro"} },
{ "keys": ["alt+k", "alt+c"], "command": "show_at_center" },
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment