Copy or move a line is a task that developers regularly do. Every text and source code editor should have this function built-in, and VSCode is no exception. In fact, VSCode does have the feature out of the box, along with a few extension that advances the editing experience that we will cover in the next sections of this article.
Delete a line in VSCode
In order to quickly delete a line in VSCode, you can simply press Ctrl+Shift+K keyboard combination while the cursor is being placed in the desired line.
The hotkey can be changed by modifying editor.action.deleteLines
key in VSCode settings.json
file. To edit the VSCode configuration, open Command Palette and find Open Settings (JSON) to open settings.json
.
// Controls the hotkey to delete a line
{
"key": "ctrl+shift+k", //REPLACE THIS
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
}
Code language: JSON / JSON with Comments (json)
Remember to replace the keyboard shortcut in the code snippet with the keyboard shortcut you want.
Cut the whole line in VSCode
Alternatively, you can press Shift + Delete to cut the line, which equals deleting the line and put in into the clipboard. This hotkey is more memorable and doesn’t involved in changing the default settings.
Also, triple click in any line will automatically select the line, after that, you can delete it using Delete key or cut it with Ctrl + X.
Quickly delete empty lines in VSCode
If your document contains a lot of empty lines or lines that contains spaces/tabs, you may want to install the Hungry Delete extension.
The extension changes the behavior of the backspace. When you hit backspace in a line that has none other than whitespaces/tabs, it erases the whole line and moves the cursor upwards to the end of the previous line. This mimics the default behavior of all the JetBrains editors (IntellJ IDEA, PyCharm, etc).

We hope that the information above is useful to you. If you’re interested in more advanced editing features of VSCode, check out our post on how to enable/disable word wrap or automatically indent your code in Visual Studio Code.