Split lines easily in Vim

Vim has a way of making me feel like a wizard one minute and a complete novice the next. I constantly feel the need to revisit the basics, and this led me to try and make J stick in my Vim vocabulary.

J joins lines, I’ve been using it regularly for a while now; it’s finally found its way into my muscle memory. It works like this.

I recently discovered a complementary plugin called vim-split-line. It makes splitting lines as easy as joining. It mirrors J, mapping by default to S. See how it works below.

There are, no doubt, countless ways to do this using Vim (in fact, the author of the plugin points this out), but I really like the simplicity of this plugin. And it handles a couple of edgecases for you too such as auto indenting the second line, and removing trailing whitespace.

Let’s hope this one sticks.