Little Known Vim Command – Join

less than 1 minute read

As the author of Mastering Vim Quickly I sometimes get various Vim related questions from my readers.

Much more often I get emails from my subscribers at masteringvim.com where I share free Vim tips.

Although this command is very simple, my experience showed that a lot of people are not aware of it. So it’s time to try to change that :)

Yesterday I was contacted by one of my readers – and as always, I try to answer my readers as soon as possible.

mastering vim quickly

 

As you can see from the screenshot, he needed to get from this

postscore(font, number, color,
lang,
size)

to this:

postscore(font, number, color,
lang, size)

He knew that there must be a better way, than going to Insert mode, and using arrow keys and Backspace. And there is.

The solution to this is simple – put your cursor anywhere on the line where lang, is, and hit J (Shift+j). That’s a join command. For more info see :help J

So, whenever you want to merge two lines into one, position the cursor anywhere on the first line, and press J to join the two lines. Simple as that :)


If you liked the post, we should get connected - follow me on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *