VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
14.02k stars 1.32k forks source link

Mapping `<S-Space>` to `<Esc>` is not working #1908

Open Sydney-o9 opened 7 years ago

Sydney-o9 commented 7 years ago

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>"]
    }
]
sdsaati commented 7 years ago

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

"vim.insertModeKeyBindingsNonRecursive": [
        {
            "before": ["<S-CR>"],
            "after": ["<Esc"]
        }
]
sdsaati commented 7 years ago

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

makcakaya commented 7 years ago

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

sdsaati commented 7 years ago

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.

makcakaya commented 7 years ago

@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.

sdsaati commented 7 years ago

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

makcakaya commented 7 years ago

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

sdsaati commented 7 years ago

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

jrwrigh commented 6 years ago

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?

jrwrigh commented 6 years ago

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.

makcakaya commented 6 years ago

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

jrwrigh commented 6 years ago

Welcome!

jpoon commented 6 years ago

https://github.com/VSCodeVim/Vim/issues/2584#issuecomment-398333458