31

I am a vim user who is moving to Sublime text and using Vintage mode. In my .vimrc I have the following line:

imap jk <Esc>

In vim, this allows me to escape out of insert mode without having to lunge for the escape key and keep my fingers on the home row. How do I do the same thing with Sublime Text Vintage mode?

5 Answers 5

48

"Vintage mode is implemented entirely via key bindings and the plugin API - feel free to browse through the Vintage package and see how it's put together. As an example, if you'd like to bind "jj" to exit insert mode, you can add this key binding:"

{ "keys": ["j", "j"], "command": "exit_insert_mode",
    "context":
    [
        { "key": "setting.command_mode", "operand": false },
        { "key": "setting.is_widget", "operand": false }
    ]
}

Just modify first line to jk if you prefer that.
Source

2
  • 1
    Thanks, that worked great! I added that fragment to Default.sublime-keymap but now I am wondering if there is a better place to override the defaults.
    – gerryster
    Commented Mar 12, 2012 at 18:15
  • 1
    Yup, probably better to do this in your User-specific keymap files if you don't want to mess with the defaults. You can get there by navigating to Preferences -> Key Bindings-User.
    – Jon
    Commented Sep 6, 2012 at 19:43
12

If you are using the Vintageous plugin, use the following key binding:

{
    "keys": ["j", "k"],
    "command": "_enter_normal_mode",
    "args": {"mode": "mode_insert"},
    "context": [{"key": "vi_insert_mode_aware"}]
}
2
  • 1
    Cool, I didn't know about Vintageous. Thanks for the tip!
    – gerryster
    Commented Sep 17, 2014 at 13:05
  • 1
    This also works with the more recent Neovintageous plugin.
    – Macondo
    Commented Jun 13, 2020 at 15:27
5

For anyone using Neovintageous 1.21.0, you can set these options in Sublime Text preferences to remap <Esc>

"vintageous_i_escape_jj": true
"vintageous_i_escape_jk": true

And that's it.

2

Also, Ctrl+[ works and is much easier to reach for than the esc key. This is in OSX at least.

3
  • It's important to note that Ctrl+[ is already taken for un-indenting a line. Ctrl+] indents.
    – John Krull
    Commented Feb 26, 2014 at 15:54
  • You must be talking about something other than OSX.
    – Scott
    Commented Feb 27, 2014 at 16:44
  • Yeah, I should have specified. I'm using Sublime Text 2 in Windows.
    – John Krull
    Commented Feb 27, 2014 at 17:11
1

You don't need to add keys configuration into preference > settings but you need to add it into preferences > keybindings. Add the following code below:

{ "keys": ["j", "j"], "command": "exit_insert_mode",
    "context":
    [
        { "key": "setting.command_mode", "operand": false },
        { "key": "setting.is_widget", "operand": false }
    ]
}

Save the file. Test it, it should work.

https://www.sublimetext.com/docs/vintage.html#included

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.