'Visual Studio Code - How to delete spaces until next word

Looking for a key combination in Visual Studio Code (VS Code) to delete all the spaces/whitespace from the cursor until the next character/word.

For example:

first words in sentence          _               last words in sentence

If my cursor is at the underscore, with a single key combination I would like to delete all the spaces between the cursor and 'last'.

Bonus points for another key combination that will delete all spaces between the cursor and the 'e' in 'sentence'.

A single key combination that deletes all spaces around the cursor is less appealing, but acceptable.

Visual Studio Code 1.63.2 (Universal)
MacOS: 12.1



Solution 1:[1]

Looking into the keyboard shortcuts and searching for 'deleteword' brought up a lot of word-deletion commands that are not mapped to keys but did not turn up in my internet searches.

I found the command deleteWordPartLeft served my purpose and I have mapped it to an unused key combination.

There are several other options, such as deleteWordPartLeft/deleteWordPartRight, deleteWordStartLeft/deleteWordStartRight, deleteWordEndLeft/deleteWordEndRight, and deleteWordLeft/deleteWordRight which might better fit your needs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JS.