15 Sep 2016

Centering the editor window in VSCode

Since its release last year, I take a glimpse at Visual Studio Code from time to time, just to see how it makes progress (after all, I’m an editor nerd).

I really like a lot of what I’ve seen so far and can recommend it as a day to day tool. One little thing that bothered me, was that there is no way to center my editor window at the current cursor position; the equivalent of “zz” in Vim or “Ctrl-L” in Emacs-ish editors. As I wanted to try out the extension system anyways, I decided to take a look at the problem to see if I can implement it myself.

I didn’t really expect this, but it turns out that writing extensions for it is dead simple and the ecosystem is quite well documented. As a bonus, I really like the whole authoring process, where you can start an additional instance of the editor via the debug menu that instantly runs your extension code to try it out – without a chance to completely mess up your editing environment. Kudos to the VSCode theme for creating such an experience.

The installable extension can be found here, source is as usual on Github.