Use Ctrl+Backspace to delete word in Windows command line?

Solution 1:

CMD or Powershell doesn't have a native shortcut to delete the word to the left or right. Here are some examples of what each platform can do. What you could probably do to make it a little easier is use the shortcut to move to the beginning or end of a word and start deleting or backspacing to delete the word.

Solution 2:

AHK Code to replicate Ctrl+Backspace functionality to delete previous word. What this does is selects the previous word with Ctrl+Shift+Left, and then presses delete. Works well enough for me in notepad, and other programs, though is bit wonky in win7. Can't confirm for terminal right now.

^BackSpace:: ;;Delete previous word
    Send ^+{Left}{Del}
 Return

Solution 3:

try this instead:

^BackSpace:: ;;Delete previous word
Send ^+{Left}
Loop, 500 {
    Send {Del}
}
Return

it modified the previous answer by sending 500 deletes after positioning at the previous word. 500 may be excessive, but so what.

this is for autohotkey (http://www.autohotkey.com/) and works in a cmd window, I put it in my cmd window specific section with the paste code like this:

#IfWinActive ahk_class ConsoleWindowClass
; Paste in command window
^V::
Send !{Space}ep
return

^BackSpace:: ;;Delete previous word
Send ^+{Left}
Loop, 500 {
    Send {Del}
}
Return

#IfWinActive