Vim: Mapping Esc to Shift-Space is not working

Created on 8 Jul 2017  路  13Comments  路  Source: VSCodeVim/Vim

It looks like trying to set ShiftSpace to escape insert mode is not working. Visual Studio Code 1.13.1 on Mac OS X.

"vim.insertModeKeyBindings": [
    {
    "before":["<S-Space>"],
    "after":["<Esc>"]
    }
]

Update 1

Trying CtrlS to save file and escape insert mode, is not working either.

"vim.useCtrlKeys": true,
    "vim.insertModeKeyBindings": [
    {
        "before": ["<C-s>"],
        "after":["<C-o>:update<CR><ESC>"]
    }
]
areremap

Most helpful comment

Looks like I figured out a way to get the Shift+Enter working correctly using the VS Code normal keybindings (ie. not going through settings.json but instead through keybindings.json):

    {
        "key": "shift+Enter",
        "command": "extension.vim_escape",
        "when": "editorTextFocus"
    }

Get's the intended effect, just maybe not in the way it should be done.

All 13 comments

Hi, I have same issue !
I want to use Shift-Enter instead of Esc but not working

"vim.insertModeKeyBindingsNonRecursive": [
        {
            "before": ["<S-CR>"],
            "after": ["<Esc"]
        }
]

I sloved my problem by creating a small application in autohotkey
my code in autohotkey (.ahk) is

<+Enter::
If WinActive("ahk_class Chrome_WidgetWin_1")
{
    Send,{Esc}
    return
}
return

but I hope this problem will be solved in visual studio code vim package

Is it possible to map Shift+Enter to Esc? A lot of Vim users use Shift+Enter as Esc.

not in VSVim itself but by using auto hotkey (it's an application you have to install) you can. I wrote the code in the above post.

@satsaeid Yep, I saw your solution, I may use that but it's not the ideal if you move from computer to computer constantly. It would be better if VSVim supported this itself.

yes it's true, specially for linux and mac maybe you can't use auto hotkey but for windows it's good and is just a little portable program. I hope one day VSVim support it, but at the moment the only option is this :)
I wrote a program that match jj as Esc with (ahk). if you want it I can email it for you. I think jj is much easier than shift+enter

@satsaeid You can map jj to Esc in VSVim too. I am more used to Shift+Enter though. :)

@makcakaya jj in English language yes, but not in other language.

Not to latch onto an old post, but I can't get the jj to Esc mapping to work. Or maybe I'm just not using it right? I figured I could check with y'all before creating an issue.

So I have the following copied into my settings.json:

"vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ]

When I'm in insert mode, and I press jj, nothing happens. It just types jj precisely as expected. Replacing the "j", "j" with "<S-CR>" also did nothing (it literally just creates a new line as expected). Am I doing something wrong? Has the feature been made defunct?

Looks like I figured out a way to get the Shift+Enter working correctly using the VS Code normal keybindings (ie. not going through settings.json but instead through keybindings.json):

    {
        "key": "shift+Enter",
        "command": "extension.vim_escape",
        "when": "editorTextFocus"
    }

Get's the intended effect, just maybe not in the way it should be done.

@u2berggeist Wow, man this is so good. Thank you for sharing it!

Welcome!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajinder-yadav picture rajinder-yadav  路  3Comments

AndersenJ picture AndersenJ  路  3Comments

Jimmy-Z picture Jimmy-Z  路  3Comments

st-schneider picture st-schneider  路  3Comments

triztian picture triztian  路  3Comments