Shortcut: Cut (or Delete) current line in Visual Studio Code (VSCode)


In order to cut the current line that your cursor is on Visual Studio Code (VS Code) make use of the below keyboard shortcuts based on the Operating System you are on.


Windows

Control + X


macOS

⌘ Command + X


Linux

Control + X


Demo:

Cut or Delete Line in VS Code Shortcut Demo

As you would see in the above demo gif image, initially the cursor was on line 3, and Command + X keys were pressed causing the line 3 to be cached in the clipboard and the lines below it were moved up.

Make use of the standard keyboard short (Control + V or Command + V on macOS) to paste the line that you just cut.

How to delete the current line?

If you want to delete (and not cut) the current line, make use of the below keyboard shortcut


Windows

Control + ⇧ Shift + K


macOS

⌘ Command + ⇧ Shift + K


Linux

Control + ⇧ Shift + K

Note this will not copy the deleted line into the clipboard.

Both cut and delete the line's shortcut also works to remove empty lines.

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap