Vscode: Backspace at end of empty line doesn't delete whole line and go to end of above line

Created on 2 Feb 2018  路  4Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.19.2
  • OS Version: W10LTSB

Steps to Reproduce:

  1. Create a new line of a block of multi-line code like an opening div tag or JavaScript or PHP function, then hit Enter.
  2. If you have an indent, continue to step 3. If not, create an indent with Tab or 4 spaces (whatever your religion is).
  3. Hit the Backspace key; notice it merely removes an indent each time instead of deleting the whole line and putting your cursor at the end of the previous line like awesome JetBrains software does. Realize how many unnecessary keystrokes you'll now have to deal with (and Ctrl+Shift+Up-End each line is still a lot).
  4. Continue to use VS Code because nobody can afford to buy another JetBrains license for your new job.

This should be standard logic in all editors; there's zero functional or stylistic reason to want to just delete indents on an empty line with Backspace (unless there's too many indents there which is rare, or your editor auto-indented wrong), and even if for some Pan-like reason you need to use that regressive space, you can just use Ctrl+Home to delete the line then indent where you want (or Shift+arrow, or just arrow if you're a weirdo).


Does this issue occur when all extensions are disabled?: Yes

editor-commands feature-request

Most helpful comment

That is something that should be implemented natively in VS Code. But for now I found this extension really useful https://marketplace.visualstudio.com/items?itemName=jasonlhy.hungry-delete

Saves up hours a day :)

All 4 comments

I like this feature idea, but one other thing to think about is the interaction with the editor.trimAutoWhitespace setting. If editor.trimAutoWhitespace is false, then I might want to delete some whitespace after hitting Enter, while still keeping the new line. And in those situations, reaching for the Backspace key would feel like the most natural way to do it.

So if this is implemented, I'd like to see a setting to turn it off for the rare cases when I might actually need to backspace over some auto-inserted whitespace (e.g., if I've turned editor.trimAutoWhitespace off for some reason).

Auto-adding whitespace should happen only after hitting Enter on an indented line, and only be added up to the beginning of the previous line or one indent more if it's inside a nesting (or maybe two more such as inside an HTML tag or PHP array so that the inner contents aren't on the same line as the following block segment), and I could see how it would be useful to just delete the empty whitespace on the line (instead of deleting the line), but this means two Backspaces to delete the line.

It's easy to see how Eclipse, JetBrains, and NetBeans editors handle Enter indentation and Backspace on empty or indent-only lines, though the JetBrains way has been the most useful and avoided the most keystrokes in my usage of all code editors I've used.

That is something that should be implemented natively in VS Code. But for now I found this extension really useful https://marketplace.visualstudio.com/items?itemName=jasonlhy.hungry-delete

Saves up hours a day :)

If #71506 is implemented, that would probably solve this one as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

biij5698 picture biij5698  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

villiv picture villiv  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments