Take the 2-minute tour ×

Is there the way to apply "greedy" behavior to and keys in Visual Studio? By "greedy" I mean such behavior when all whitespace between cursor position and next word bound can be deleted using one keystroke.

share|improve this question

8 Answers 8

up vote 6 down vote accepted

Well, I don't think you can change the binding of the delete key or backspace key - but CTRL+DEL & CTRL+Backspace are pretty close to what you want.

share|improve this answer

Just Ctrl+Backspace...

share|improve this answer
This will erase all space AND the last word too... I just tested it. –  Patrick Desjardins Sep 18 '08 at 13:10

You can use Ctrl+Shift+Arrow keys to make the selection and then just hit Delete. You may need to hit the arrow key more than once while still pressing Ctrl+Shift combination but because the fingers are in the same position is very fast. This works also for selecting words incrementally.

share|improve this answer

Sounds like something you could write a macro for and then assign to a keyboard shortcut (like SHIFT+DEL).

If you explore the EnvDTE namespaces you can do a lot to make changes to text in the active document window. I'd start by checking with something like...

    Public Sub RemoveWhiteSpace()
        DTE.ActiveDocument.Selection.Text = " "
    End Sub

That's just a simple example, but you can extend it further pretty easily

share|improve this answer

Actually, you will need to do this: Ctrl+Shift+Left+Right - this will give you only the space selected, and then you can press delete.

This is assuming that you are coming from the right, and you have to delete the space to the left.

Of course, this is still 5 keystrokes... but it beats pressing backspace again and again....

share|improve this answer

Ctrl+Back Space and Ctrl+Delete are also greedy, they delete the nearest word in their respective direction.

share|improve this answer

OK I've got this < Ctrl > thing. And applying this knowledge I've found corresponding VS commands: Edit.WordDeleteToStart and Edit.WordDeleteToEnd.

I've successfully remapped < Delete > and < Backspace > keys using Options->Environment->Keyboard dialog. Unfortunately this commands apply not only to whitespace as I'd wish to, but still, thanks everyone!

share|improve this answer

You are looking for:


I have it set to Ctrl+K, Ctrl+\ which I think is the default, but might not be

share|improve this answer

Your Answer


