If you are like me and have spent most of your time programming in Linux or Windows, then switching over to OSX can be tricky. Keyboard shortcuts have changed and you have to deal with the placement of that pesky fn key. I've listed below my complete Default (OSX).sublime-keymap file.

The keymap file contains many common keyboard shortcut conversions. Most of these deal with switching the apple key (command key) for the ctrl key. I've made a note at the bottom about the annoying f5 keymapping for sorting a document alphabetically. There is probably a way to remove the original mapping or set it to do nothing, I have tried to use the noop command. But so far it is still persisting. If anyone knows of a fix I would love to see it in the comments.

Additionally, I added some layout mappings for some swanky custom layouts.

Default (OSX).sublime-keymap

[
    { "keys": ["ctrl+x"], "command": "cut" },
    { "keys": ["ctrl+c"], "command": "copy" },
    { "keys": ["ctrl+v"], "command": "paste_and_indent" },
    { "keys": ["ctrl+s"], "command": "save" },
    { "keys": ["ctrl+z"], "command": "undo" },
    { "keys": ["ctrl+shift+z"], "command": "redo" },
    { "keys": ["f3"], "command": "find_next" },
    { "keys": ["ctrl+g"], "command": "find_next" },
    { "keys": ["ctrl+shift+g"], "command": "find_prev" },
    { "keys": ["shift+f3"], "command": "find_prev" },
    {
        "keys": ["super+shift+1"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 1.0],
            "rows": [0.0, 1.0],
            "cells": [[0, 0, 1, 1]]
        }
    },
    {
        "keys": ["super+shift+2"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 0.5, 1.0],
            "rows": [0.0, 1.0],
            "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
        }
    },

    // side-by-side column with small row underneath
    {
        "keys": ["super+shift+3"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 0.5, 1.0],
            "rows": [0.0, 0.8, 1.0],
            "cells": [[0, 0, 1, 1], [1, 0, 2, 1], [0, 1, 2, 2]]
        }
    },
    // 2 rows, 3 columns
    {
        "keys": ["super+shift+5"],
        "command": "set_layout",
        "args":
        {
            "cols": [0.0, 0.33, 0.67, 1.0],
            "rows": [0.0, 0.5, 1.0],
            "cells": [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3, 1],
            [0, 1, 1, 2], [1, 1, 2, 2], [2, 1, 3, 2]]
        }
    },
    { "keys": ["ctrl+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
    { "keys": ["ctrl+shift+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
    { "keys": ["super+ctrl+p"], "command": "prompt_select_workspace" },
    { "keys": ["ctrl+r"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
    { "keys": ["ctrl+k"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
    { "keys": ["home"], "command": "move_to", "args": {"to": "bol"} }, // fix the home key
    { "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }, // fix the end key
    { "keys": ["super+shift+a"], "command": "alignment" },
    { "keys": ["ctrl+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"} },
    { "keys": ["ctrl+shift+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line Before.sublime-macro"} },
    { "keys": ["ctrl+d"], "command": "find_under_expand" },
    { "keys": ["ctrl+shift+up"], "command": "swap_line_up" },
    { "keys": ["ctrl+shift+down"], "command": "swap_line_down" },
    { "keys": ["f1"], "command": "dash_doc" },
    { "keys": ["ctrl+shift+super+d"], "command": "clone_file" }, // Duplicate the current file view, useful for looking at different places at the same time in the same file
    {
        "keys": ["ctrl+forward_slash"], "command": "toggle_comment", "args": { "block": false }
    },

    // Attempting to reset the sort lines shortcut. On OSX when using workspaces quickly
    // switching between a browser and sublime while pressing f5 will sort text editor lines
    // alphabetically.
    { "key": ["f5"], "command": "noop" },
    { "key": ["ctrl+f5"], "command": "noop" },
    { "keys": ["shift+ctrl+f5"], "command": "sort_lines", "args": {"case_sensitive": false} },
    { "keys": ["shift+super+ctrl+f5"], "command": "sort_lines", "args": {"case_sensitive": true} },
]
« Previous Post
Drying out your content with Ruby on Rails Internationalization
Next Post »
The year in review (2015)

Join the conversation

comments powered by Disqus