Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code, navigate within a wrapped line vs jumping to next line

In vs code I've noticed that when line wrap is enabled using the arrow keys to go to the next line causes the cursor to skip over any wrapped content and go to the next editor line. Is there any way to make navigation go to the next visual line instead? Given the below snippet: if my cursor is on the t of this in line 1 and I hit down, is there a way to have the cursor go to the a in automatically rather than the t in this on line 2?

1 this is a line that
  automatically wraps 
2 this is another line
3
like image 414
Greg Ruhnow Avatar asked Dec 13 '22 20:12

Greg Ruhnow


2 Answers

Evidently the issue I was facing was VIM specific standard behavior. At some point I must have used a vim implementation that defaulted j and k to gj and gk respectively. I was able to recreate this behavior by adding the following to my vs-code options:

  "vim.otherModesKeyBindingsNonRecursive": [
    {
        "before": ["j"],
        "after": ["g", "j"]
    },
    {
        "before": ["k"],
        "after": ["g", "k"]
    }
  ]
like image 82
Greg Ruhnow Avatar answered May 15 '23 14:05

Greg Ruhnow


It seems that the vim.otherModesKeyBindingsNonRecursive setting now is gone and I use this instead:

  "vim.normalModeKeyBindingsNonRecursive": [
    {
        "before": ["j"],
        "after": ["g", "j"]
    },
    {
        "before": ["k"],
        "after": ["g", "k"]
    }
  ]
like image 35
Alexey Zimarev Avatar answered May 15 '23 14:05

Alexey Zimarev