Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center the editor window back on the cursor in VSCode?

Tags:

I'm using VSCode as my text editor. I'm curious, is there a keybinding for centering the editor window on the cursor, when the window is a lot of lines below/above it such that it's not visible on the screen? I've tried looking at the default keybindings by going to FIle > Preferences > Keyboard Shortcuts, but I see no such options for centering the window.

like image 433
James Ko Avatar asked Dec 11 '16 03:12

James Ko


People also ask

What does Ctrl d do in VS Code?

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection. Tip: You can also add more cursors with Ctrl+Shift+L, which will add a selection at each occurrence of the current selected text.

How do you step back in VS Code?

You can do step-back to the previous line in VS code via the use of the new Step Backward icon while debugging your code with IntelliTrace Debugging. Now you can go to the previous line while debugging with the help of the step backward icon.


3 Answers

There is no such keybinding / command built-in.

I couldn't stand that either, so I created a VSCode extension. You can find it and install it here on the marketplace. The default shortcut is CTRL + L.

like image 91
kwood Avatar answered Oct 12 '22 23:10

kwood


If you are using vscodevim, zz should work.

like image 43
Martin Ney Avatar answered Oct 12 '22 22:10

Martin Ney


If you want to always keep the cursor on the center, you can change the setting Cursor Surrounding Lines to a really high number (100 is ok) and that should work.

like image 20
MARTIN ANSELMO IDUYA Avatar answered Oct 13 '22 00:10

MARTIN ANSELMO IDUYA