1

If I have a commandline like this:

sunday.exe monday tuesday-wednesday

I would like to delete to the last space, or essentially the last argument. I tried Ctrl + Backspace, but it deletes only to the first hyphen. Is this possible?

1
  • You would have to change what power shell command line uses for word boundaries. I don't think this is possible.
    – DavidPostill
    Commented Jun 19, 2020 at 6:32

2 Answers 2

1

To view current delimiters:

(get-PSReadLIneOption).WordDelimiters

To remove the "-" character (current session):

(get-PSREadLIneOption).WordDelimiters = (get-PSREadLIneOption).WordDelimiters -replace '-'

To restore defaults:

(get-PSREadLIneOption).WordDelimiters = @'
;:,.[]{}()/\|^&*-=+'"–—―
'@
1

Not something native in PowerShell.

You'd have to mess with PSReadline customizations.

about_PSReadLine

BackwardWord

Move the cursor back to the start of the current word, or if between words, the start of the previous word. Word boundaries are defined by a configurable set of characters.

Cmd: <Ctrl+LeftArrow> Emacs: <Alt+b>, <Escape,b> Vi insert mode: <Ctrl+LeftArrow> Vi command mode: <Ctrl+LeftArrow>

https://docs.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-7

And remember that PSReadline is only a consolehost thing, not the ISE or VSCode which would require separate configuration or add-on.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .