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

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.


As @kwood put it, there is an extension Center Editor Window in the marketplace that meets this end.

I would like to make an answer here, to complement that -- even the extension's author did not explicitly state in the marketplace page -- if you would like to change the default key binding (Ctrl+L), you may try put the following lines in the keybindings.json for the keyboard bindings.

{
    "key": "cmd+k cmd+c",
    "command": "center-editor-window.center",
    "when": "editorTextFocus"
},

The above command sets ⌘ Command+K, ⌘ Command+C as the keyboard shortcut.


Apart from that, you may set

"center-editor-window.threeStateToggle": true,

in the settings.json for VS Code settings so that it will switch among three states (center, top, bottom) instead of one (center).


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.


If you are using vscodevim, zz should work.