question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

visual mode: gj/gk not working in wrapped lines

See original GitHub issue

This is based on issue #90 but for visual mode instead of normal mode. Currently it is not possible to jump over wrapped lines with gj/gk when visual mode is on.

I tried to copy these lines: https://github.com/asvetliakov/vscode-neovim/blob/6469c216f30c4bf29d5718f6d3fe99d517a33db0/vim/vscode-motion.vim#L15-L16

and changed them to vnoremap:

vnoremap gk <Cmd>call VSCodeNotify('cursorMove', { 'to': 'up', 'by': 'wrappedLine', 'value': v:count ? v:count : 1 })<CR> 
vnoremap gj <Cmd>call VSCodeNotify('cursorMove', { 'to': 'down', 'by': 'wrappedLine', 'value': v:count ? v:count : 1 })<CR> 

Afterwards the movement works but it doesn’t update the selection. Here the cursor is in line 17 but the selection is still stuck in line 18. image

I checked the API and there is the select argument for cursorMove.

vnoremap gk <Cmd>call VSCodeNotify('cursorMove', { 'to': 'up', 'by': 'wrappedLine', 'value': v:count ? v:count : 1, 'select': true})<CR>
vnoremap gj <Cmd>call VSCodeNotify('cursorMove', { 'to': 'down', 'by': 'wrappedLine', 'value': v:count ? v:count : 1, 'select': true})<CR

But i get an error that the variable true is undefined: emsg: E121: Undefined variable: true

Any ideas how i can use the select argument?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jweickmcommented, Aug 18, 2022

That’s too bad. Would love to see this functionality added into VSCode Neovim.

0reactions
theol0403commented, Apr 30, 2022

Not a priority, but the problem is that vscode moves the cursor but then does not tell nvim about the new cursor position to extend the visual selection. Either the gj/gk hack could be removed, or there needs to be some code that extends the visual selection.

Read more comments on GitHub >

github_iconTop Results From Across the Web

visual mode: gj/gk not working in wrapped lines #576 - GitHub
This is based on issue #90 but for visual mode instead of normal mode. Currently it is not possible to jump over wrapped...
Read more >
how can i intuitively move cursor in vim?(not by line)
If you want to navigate wrapped lines use gk or gj , or just as some like it, map it to for example,...
Read more >
neovim - Wrapping comment in visual mode not working with gq
I'm using neovim. When I visually select a comment in Python that is longer than my textwidth setting, and press gq , it...
Read more >
Visual Line Mode (GNU Emacs Manual)
This makes the text easier to read, as wrapping does not occur in the middle of words. Word wrap is enabled by Visual...
Read more >
Wrap text in a cell - Microsoft Support
Microsoft Excel can wrap text so it appears on multiple lines in a cell. ... If all wrapped text is not visible, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found