Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Cannot make a key binding for Shift+Enter (normalModeKeyBindingsNonRecursive)

Open kennysong opened this issue 5 years ago • 5 comments

Describe the bug

I'm trying to remap <Enter> and <Shift>+<Enter> to create new lines in Vim normal mode.

<Enter> works as intended, but <Shift>+<Enter> doesn't work. Here's the relevant setting.json:

    "vim.normalModeKeyBindingsNonRecursive": [
      {
          "before": ["<Enter>"],
          "commands": ["editor.action.insertLineAfter"]
      },
      {
        "before": ["<Shift>", "<Enter>"],
        "commands": ["editor.action.insertLineBefore"]
      }
    ],

I've tried other strings like <S-CR>, which don't work either. What am I missing?

(I've also disabled all Keyboard Shortcuts that use shift+enter.)

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.16.0
  • VSCode version: 1.47.3
  • OS: macOS 10.15.6

kennysong avatar Aug 12 '20 05:08 kennysong

Try <shift+enter>. I cant tell for sure it will work, but from looking at the code, thats what I would try.

sql-koala avatar Aug 12 '20 06:08 sql-koala

@sql-koala Thanks for the suggestion – unfortunately <shift+enter> doesn't work either.

None of these variants work so far:

  • ["<Shift>", "<Enter>"]
  • ["<Shift><Enter>"]
  • ["<Shift>+<Enter>"]
  • ["<S-CR>"]
  • ["<shift+enter>"]

kennysong avatar Aug 12 '20 07:08 kennysong

Looks like we don't currently capture <Shift+Enter>

J-Fields avatar Aug 12 '20 14:08 J-Fields

I'd also love this to work, though to be fair it doesn't work in some terminals either. I use "Enter" to insert blank lines in normal mode, and like to use "Shift+Enter" to insert blank lines above the cursor.

s-taylor avatar Jan 20 '22 01:01 s-taylor

Hey 👋 Trying to get this working too, did someone find an alternative solution?

giopetris avatar Aug 03 '22 16:08 giopetris

@giopetris @kennysong

Go to your keybindings.json and add the following for the Shift + Enter combination:

{
    "key": "shift+enter",
    "when": "inputFocus && vim.mode == 'Normal'",
    "command": "editor.action.insertLineBefore",
}

This should fix the problem.

733amir avatar Jan 04 '23 19:01 733amir

Oh that works, thanks for the workaround!

kennysong avatar Jan 05 '23 00:01 kennysong