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.

motion does not work properly in visual mode

See original GitHub issue

Steps to reproduce:

  1. Open a new file with neovim plugin enabled
  2. type iabc<Esc>yy99p to insert 100 lines of abc
  3. type V
  4. type M, or L, or <ctrl-f>, or <ctrl-d>

Expected behavior: Lines from line 2 to the middle or last line of the screen should be selected.

Actual behavior: Only line 2 is selected, while the cursor is at the middle or the last line of the screen.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
ssipos90commented, Mar 25, 2021

+1, I use shift+V (visual line) with ctrl+d or ctrl+u for half page selection most of the times.

Only the viewport is moving, not the cursor.

1reaction
theol0403commented, Jun 5, 2021

It looks like this is because vscode intercepts these commands and does not update neovim after scrolling. The reason vscode intercepts these commands instead of delegating to neovim is, according to @asvetliakov, “cursor jitter” and other problems.

However, when I disable the interceptions, it actually seems to work alright.

Here is how you can do this:

    {
        "key": "ctrl+d",
        "command": "-vscode-neovim.ctrl-d",
        "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'"
    },
    {
        "key": "ctrl+u",
        "command": "-vscode-neovim.ctrl-u",
        "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'"
    },
    {
        "key": "ctrl+f",
        "command": "-vscode-neovim.ctrl-f",
        "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'"
    },
    {
        "key": "ctrl+b",
        "command": "-vscode-neovim.ctrl-b",
        "when": "editorTextFocus && neovim.ctrlKeysNormal && neovim.init && neovim.mode != 'insert'"
    },
    {
        "command": "vscode-neovim.send",
        "key": "ctrl+d",
        "when": "editorTextFocus && neovim.init && neovim.mode != insert || neovim.recording",
        "args": "<C-D>"
    },
    {
        "command": "vscode-neovim.send",
        "key": "ctrl+u",
        "when": "editorTextFocus && neovim.init && neovim.mode != insert || neovim.recording",
        "args": "<C-U>"
    },
    {
        "command": "vscode-neovim.send",
        "key": "ctrl+f",
        "when": "editorTextFocus && neovim.init && neovim.mode != insert || neovim.recording",
        "args": "<C-F>"
    },
    {
        "command": "vscode-neovim.send",
        "key": "ctrl+b",
        "when": "editorTextFocus && neovim.init && neovim.mode != insert || neovim.recording",
        "args": "<C-B>"
    },

Disabling H/M/L is a bit trickier, because it is defined here: https://github.com/asvetliakov/vscode-neovim/blob/ba50a353ee5b188d963be7561803f96a587b733f/vim/vscode-scrolling.vim#L25-L30

Adding this to the bottom of my init.vim seems to have solved it:

  unmap H
  unmap M
  unmap L

However, I’m not sure if that works 100% of the time, because it seems like in some cases unmapping does not seem to have an effect (#631). Let me know if it works for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

motion does not work properly in visual mode #580 - GitHub
It's causing the cursor to move to the top/bottom/middle of the file and not the viewport. All reactions.
Read more >
visual line mode is ended by inner block motion
Because, text-objects are supposed to work with visual-mode and after an operator, see :h text-objects .
Read more >
What's causing this weird movement behavior in visual mode?
The problem is in visual mode. If I enter visual mode, then press w , the cursor moves down three lines, like expected....
Read more >
:action commands don't work in Visual mode : VIM-958
You can see that it recognizes normal mode motion, but doesn't set visual mode one. upd, it seems that's not the case. for...
Read more >
Mastering Visual Mode in Vim - DEV Community ‍ ‍
To use visual mode operators, first visually select an area of text ( v/V/Ctrl-v + motion), then press a visual-mode operator key. That's...
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