amVim-for-VSCode
amVim-for-VSCode copied to clipboard
Screen Line/Character movement support
We added screen line/character movement command in Visual Studio Code in July. The commands is like
cursroMove({to: 'lineStart', inSelectionMode: true});
More details are listed in https://github.com/Microsoft/vscode/issues/2771 . Leveraging thse commands, following Vim commands can be implemented real quick
- g0
- g^
- g$
- gm
- gj
- gk
Would definitely like to see this added! :+1:
A workaround for now regarding gj
and gk
:
The keybindings below will make j and k behave like gj
and gk
for amVim normal mode for moving among displayed lines in word wrapping mode.
Ref: My pull request to VSCodeVim https://github.com/VSCodeVim/Vim/pull/3623
{
"key": "up",
"command": "cursorUp",
"when": "editorTextFocus && amVim.mode == 'NORMAL' && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
},
{
"key": "down",
"command": "cursorDown",
"when": "editorTextFocus && amVim.mode == 'NORMAL' && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
},
{
"key": "k",
"command": "cursorUp",
"when": "editorTextFocus && amVim.mode == 'NORMAL' && !inDebugRepl &&!suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
},
{
"key": "j",
"command": "cursorDown",
"when": "editorTextFocus && amVim.mode == 'NORMAL' && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
}
@aioutecism I will test this for a while and if it continues to work well, I would open a pull request documenting this in the readme, if you'd be open to that.
@karlhorky Thank you for this. I’m not sure this will work for commands such as ‘dj’. Have you get it to work as expected?
Yes, this is a caveat of this approach, motions like dj
or 10j
do not work. I would include this in the documentation.
Support for gj
, gk
, g0
, g^
, g$
and gm
has been merged and will be available in the next release. There are some unavoidable quirks around flashing/jumping cursor, and there remains some off-by-one strangeness in visual mode, but I think it's good enough to close this issue.