Open mccreeker opened 6 years ago
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.
+1
Still looking for this solution. Any updates?
@edgarwideman Have you tried this extension yet? It worked almost as well as how the JetBrains IDEs do it for me. Just not well enough to justify closing this issue just yet, in my opinion. https://marketplace.visualstudio.com/items?itemName=jasonlhy.hungry-delete
I did find it after dropping previous comment. Thanks anyway. 👍
Related on Stack Overflow: Move cursor up after deleting a line in VSCode
If there were a context key that contained the text preceding the cursor in its current line, or even one containing the entire contents of the current line, you could write a keybinding that would do this using various editor commands in runCommands
and with a when clause using the match operator.
I posted a possible solution on SO: https://stackoverflow.com/a/78290422/836330
It is just a keybinding, no extension necessary.
Steps to Reproduce:
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