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.

-


Have Questions? Post them here!

Top Hashtags:

Advertisements

Advertisements




Advertisements