Become a member
to unlock all features

Level Up!

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


    Expand and Shrink Selection with VSCode

    Kent C. DoddsKent C. Dodds
    vscodeVS Code

    Expanding and shrinking selection with VSCode's built-in intelligent selection feature makes refactoring code a breeze. In this lesson, learn how to do this with the ⌃⇧⌘← and ⌃⇧⌘→ keyboard shortcuts.



    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: I got this counter component, and I want to refractor this a little bit so I can extract this on quick handler to a named function. The quickest way for me to do that is to put my cursor somewhere in the function, then hit control-shift-command, and then right arrow. This will expand my selection.

    It does so intelligently so that it expands to the right code tokens so that it actually makes sense. If I start here, it just grabs the identifier, and then I do right again, and that grabs the whole expression. I do right again, that grabs that whole arrow function right there.

    I do it again, and it grabs the function call of set count. One more time, that grabs the whole function. I can cut this, call this, increment, and then increment right here, and just paste it right there.

    Because VS Code does this intelligently, even if I have things formatted in a really funny way, this will still work by hitting control-command-shift, right, right, right. It's going to grab the whole expression. Now it grabs the whole arrow function just like it was before, because VS Code is doing this intelligently.

    That's control-shift-command, right, and left to expand and shrink selection intelligently with VS Code.