Vim
Vim copied to clipboard
Cannot make a key binding for Shift+Enter (normalModeKeyBindingsNonRecursive)
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
Try <shift+enter>.
I cant tell for sure it will work, but from looking at the code, thats what I would try.
@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>"]
Looks like we don't currently capture <Shift+Enter>
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.
Hey 👋 Trying to get this working too, did someone find an alternative solution?
@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.
Oh that works, thanks for the workaround!