Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    VSCode Multi Cursors: Keyboard & Mouse/Touchpad Workflows

    Ahmad Awais ⚡Ahmad Awais ⚡
    vscodeVS Code

    VSCode multi-cursors are super fun to use. In this lesson you'll learn everything there is to know about using multi-cursors both with keyboards and mouse/touchpad.

    Pre-Requisite: All the keyboard shortcuts shown in the video are for macOS on VSCode with the "Sublime Text Keymap" Extension installed. You can either use my setup or search for what these shortcuts look like on your installation by clicking the gear icon (left-bottom) and selecting Keyboard Shortcuts (and then search for the required shortcut).



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: A couple of years ago, just like you, I was trying to learn all these power user workflows. Today is your lucky day because I am going to teach you how to deal with lines, how to juggle with words, and how to do those multi-cursors thing, if you know what I mean.

    Anyway, before we start, I need to tell you that I am using MacOS. When I say Command, that should be Control on Windows or Linux or other OS. Similarly, when I say Option, you should know that I mean Alt on other OS.

    Let's begin. Now let's talk about one of my favorite workflows, the multi-cursor workflows. You're going to be using the mouse or keypad for this multi-cursor workflow. Let's say you want to change all of these background colors to a one single similar color. What you can do is you can press and hold Command and then click wherever you want.

    See, my cursor is growing in size and now I can select it and make it wide, or whatnot. Again, press and hold Command and then click. See. Now all these areas are editable.

    I can also drag a multi-cursor. For that, I need to press and hold Command and Shift. For example, let's say I want three cursers, here, here, and here. Let's put our cursor here, press and hold Command and Shift. Now drag this cursor down here. Now I have these three cursors.

    I can do it in a much larger way as well. For example, let's put our cursor here. Press and hold Command and Shift, and drag and down to here. See how many cursors we have, one cursor for every line from 720.

    Whether you want to create a multi-cursor with keyboard without even using a mouse or keypad, you can do that very easily. For example, let's again do same thing here. See in the background inaudible of all these buttons to buy tomato.

    I'm going to press and hold Command and Alt, and then I'm going to press the down key. Now I can select them and tomato here. Tomatoes are inaudible . Now I can press Escape to escape out of these multi-cursors. Similarly, I can go up as well. Press and hold Command and Alt, and press the up button. There you go. That's pretty cool.

    Now let's do the multi-cursor selection thing with just keyboard. What I want is three cursors here, here, and here. I'm going to use keyboard only to do this. I've pressed Shift and then down, down, down to select these three lines. Now I'm going to press Command, Shift, and L and boom, there are these three cursors that we needed.

    Let me do this again. Shift and down to select these lines. Now Command, Shift and L. There you go. We have as many cursors as we want. Let's select all of this file with Command A and Command, Shift, L with four cursors after every single line. That's pretty cool.

    The last one here is how to undo the last cursor. Imagine you wanted to change these colors. You press Command and Alt, and then down, down, down. There is this extra cursor that you didn't need. Press Command U and you will undo the last cursor action. Command U, Command U.

    Similarly, if you are going up, then, then, then, Command U, Command U. Command U will just undo the last action of your cursor.

    This is also true for your mouse and keypad. Click here, select Command and Shift, and then drag it out here. We didn't need this last one. I am going to press Command U, and there it's gone.