Have you heard about Envirotechnical? Let's fight climate change one byte at a time :) Learn More →

logo
Published on

Multicursor in VSCode, a productivity boost

Authors
Table of Contents

The why

I think there are at least two very specific kinds of Developers. There's the very productive kind that can automate anything with the blink of an eye and then there's us, the common folks, those that avoided shortcuts for all their lives because learning a key sequence by muscle might take at least 15 seconds and that's a time we'd rather use to browse the Internet randomly, for no apparent reason whatsoever.

If, like me, you're part of the common rabble, that also means that you feel jealous whenever someone of your tribe, The Cool Developers, uses some kind of really fascinating ultra productive key sequence that would take you actual labor if you wanted to apply the same changes your friend did.

But don't worry, as usual this blog post is here to answer your gloomy questions because, pretty much like me, you came to a point in your developer's life where you cannot be unwilling to acknowledge the sublime power of shortcuts and terminal powerapps.

Leonardo Di Caprio welcomes you to Multicursors

The how

You don't need to be afraid, this post won't be long. Afterall, it is about shortcuts, isn't it?

Infact, I'll use exactly this post to showcase what can be done with them.

All you need to do is press the button (Alt for other keyboards)

Alt button cursor to move code block up and down

As you can see, it's already kind of cool that you can move single lines of code around without even touching your mouse and selecting the lines you want to move, but what if you wanted to move code blocks?

Same story.

(SHIFT) to select more lines.

(ALT) to move them around.

(CTRL) to go to the end of the line.

Alt button cursor to move code block up and down

Want to copy a line of code without too much fuss?

+ (SHIFT + ALT) and just move vertically in your codebase

Alt and shift to copy lines

This trick can be used also with multiple selected lines! Isn't it amazing?!

Alt button cursor to copy code block up and down

But you can also do nice stuff like manually adding cursors with your mouse! + Click

Alt and shift to copy lines

And for our last shortcut, behold!, the Search and Replace cursors!

+ to open up the Search input in VSCode

+ + to place the cursors

And there you have them, multicursors in all of their glory!

Multicursors with search on VSCode

The goodies

Y'all got any more of those shortcuts for VSCode?

You've learnt a lot in just a few minutes and gifs, congratulations! Now go and use your new found powers in VSCode, and remember, be good lazy.

Happy hacking!

The goodbye

I hope you found this article useful and to your liking and if you have any requests, drop a message on one of my social media accounts or open an issue/start a discussion on github, on this repository!