user6069704
user6069704

Reputation:

Delete all words in the current line and leave it a blank line in vscode

In VSCode, we can use a shortcut to delete the current line. But sometimes I want to rewrite the current line, so I don't want to delete the line when we are deleting all the words. Is there any way to delete all words but don't delete the current line?

Upvotes: 7

Views: 9904

Answers (5)

Hamza Waleed
Hamza Waleed

Reputation: 1462

  1. Select the line you want to delete and then press Ctrl + Shift + K. This will delete the entire line.
  2. Place the cursor at the end of the line you want to delete and press Command + Delete. This will delete all the text to the left of the cursor.

Upvotes: 0

Szymon
Szymon

Reputation: 143

The simplest way is Shift +Del , but delete the current line

Upvotes: 5

Sylvain P
Sylvain P

Reputation: 11

You can use Ctrl+x and Ctrl+Shift+Enter.

Upvotes: 1

juzraai
juzraai

Reputation: 5943

I looked through Keyboard Shortcuts of VS Code, it doesn't have such thing as deleting contents of a line and leaving the empty line.

You can use one of the following combinations:

  1. Home then Shift+End (or End then Shift+Home) to select the contents, then Delete or start typing (as you want to rewrite the line)
  2. Ctrl+Shift+K to delete line, then Ctrl+Shift+Enter to insert new line above. This will move the cursor to the empty line so you can start typing the new content.

Upvotes: 5

Mark
Mark

Reputation: 180651

There is a useful command deleteAllLeft and deleteAllRight which are unbound by default. So try in your keybindings.json:

{
  "key": "ctrl+shift+backspace",
  "command": "deleteAllLeft"
}

It will delete any indentation on the left as well - until your formatter kicks in however you have it set up.

Upvotes: 11

Related Questions