amVim-for-VSCode icon indicating copy to clipboard operation
amVim-for-VSCode copied to clipboard

Screen Line/Character movement support

Open rebornix opened this issue 8 years ago • 5 comments

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

rebornix avatar Jul 29 '16 09:07 rebornix

Would definitely like to see this added! :+1:

zolrath avatar Nov 30 '16 22:11 zolrath

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"
  }

karlhorky avatar Jun 24 '19 08:06 karlhorky

@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 avatar Jun 24 '19 10:06 karlhorky

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

aioutecism avatar Jun 24 '19 10:06 aioutecism

Yes, this is a caveat of this approach, motions like dj or 10j do not work. I would include this in the documentation.

karlhorky avatar Jun 24 '19 10:06 karlhorky

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.

alisonatwork avatar Oct 30 '22 04:10 alisonatwork