Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code - keyboard shortcut to Move Cursor to the center of current screen After Keyboard Scrolling

After you scroll in the Editor using the keyboard (Ctrl+UpArrow/DownArrow), the cursor stays behind where it was, maybe 5-10 screens back.

Is there a command to move the cursor into the center of the current screen that I am viewing, so that I can edit whatever I am looking at?

I could do "Go To Line" (Ctrl+G, then type the line number), but I am looking for a single-press keyboard shortcut.

like image 587
Kirill Yunussov Avatar asked Aug 09 '19 19:08

Kirill Yunussov


People also ask

How do I move the cursor on a Windows PC?

Moving the Cursor on a Windows PC Move Cursor To Keyboard Shortcut the top of the page CTRL + HOME the bottom of the page CTRL + END one word to the right CTRL + RIGHT ARROW one word to the left CTRL + LEFT ARROW 2 more rows ...

How do I set cursors above or below the current position?

To set cursors above or below the current position use: Keyboard Shortcut: Ctrl+Alt+Up or Ctrl+Alt+Down You can add additional cursors to all occurrences of the current selection with Ctrl+Shift+L.

How do I move the cursor in VSCode?

Use ctrl + Up/Down Arrow to move. I have linux and the vim extention for vscode. This command scrolls the view but not the cursor. So, keep that in mind. does the mouse roller even move the cursor?

Is there a way to scroll in Visual Studio 2015?

I used to be able to scroll in Visual Studio 2015 using some keyboard shortcuts in Windows doing something like ctrl shift down. It would effectively behave like a line by line viewport bump that did not modify where my cursor was inserted at.


1 Answers

Try this in your keybindings.json:

{
  "key": "alt+m",           // or whatever binding you choose
  "command": "cursorMove",
  "args": {
      "to": "viewPortCenter"
  }
}

See also: to automatically move cursor as you scroll if that is desirable.

like image 66
Mark Avatar answered Nov 15 '22 09:11

Mark