Search code examples
sublimetext3key-bindings

Is it possible to use C-x C-s for saving in Sublime Text 3


In Sublime Text 3 is it possible to use C-x C-s for saving the file (save_all), while keeping C-s for search option?


ctrl+x+s or ctrl+xctrl+s did not work on my end.

{ "keys": ["ctrl+s"], "command": "find_next", "context":
        [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
},
{ "keys": ["ctrl+x"], "command": "noop" },
{ "keys": ["ctrl+x+s"], "command": "save_all" },
{ "keys": ["ctrl+x+ctrl+s"], "command": "save_all" }

Solution

  • Binding key chords like this in Sublime requires you to specify both keys individually in the keys list (that's why it's a list).

    So, what you want is:

    { "keys": ["ctrl+s"], "command": "find_next", "context":
            [{"key": "panel", "operand": "find"}, {"key": "panel_has_focus"}]
    },
    { "keys": ["ctrl+x"], "command": "noop" },
    { "keys": ["ctrl+x", "ctrl+s"], "command": "save_all" },
    
    

    Note that the binding of Ctrl+x to noop is not needed for this to work, so you can leave that out. However using the same key for both single items and in chords like this may require you to hit the key twice to get Sublime to trigger the command, since it otherwise can't tell without some delay which of the bindings you intended.