Powershell hot key ctrl j and ctrl w #5475

Closed
opened 2026-01-31 00:14:15 +00:00 by claunia · 2 comments
Owner

Originally created by @Xdminsy on GitHub (Dec 9, 2019).

#Environment

Windows build number: Microsoft Windows [Version 10.0.18362.356]
Windows Terminal version (if applicable): 0.7.3382.0


Any other software?
Powershell Core: 7.0.0-preview.6

I used to bind ctrl+j to enter and use ctrl+w to backward delete word. I have

Set-PSReadLineOption -BellStyle None -EditMode Emacs

emacs edit mode enabled in my powershell.
The ctrl+w works differently in powershell and in powershell in windows terminal.
If I input Get-Command and type ctrl+w, only the Command wil be deleted in powershell.
But in Windows terminal the Get- will be deleted as well.
I don't understand why, but if I explicitly add this to $PROFILE

Set-PSReadLineKeyHandler -Chord ctrl+w -Function BackwardDeleteWord

It works in terminal as expected.

Though ctrl+w can work as expected if I add one line, the ctrl+j cannot work,

Set-PSReadLineKeyHandler -Chord ctrl+j -Function AcceptLine

In powershell I can use ctrl+j instead of Enter key to run command.
But in powershell in Windows Terminal this doesn't work, ctrl+j do nothing even if I mapped it to something.
Other keys seem to work, I only found the binding for ctrl+j won't work.
I thought terminal deals with ctrl+j itself instead of sending it to powershell, but I tried mapping ctrl+j in vim running in terminal it worked.

So I don't understand why these happen, why?

Originally created by @Xdminsy on GitHub (Dec 9, 2019). #Environment ```none Windows build number: Microsoft Windows [Version 10.0.18362.356] Windows Terminal version (if applicable): 0.7.3382.0 Any other software? Powershell Core: 7.0.0-preview.6 ``` I used to bind ctrl+j to enter and use ctrl+w to backward delete word. I have ```powershell Set-PSReadLineOption -BellStyle None -EditMode Emacs ``` emacs edit mode enabled in my powershell. The ctrl+w works differently in powershell and in powershell in windows terminal. If I input `Get-Command` and type ctrl+w, only the `Command` wil be deleted in powershell. But in Windows terminal the `Get-` will be deleted as well. I don't understand why, but if I explicitly add this to $PROFILE ```powershell Set-PSReadLineKeyHandler -Chord ctrl+w -Function BackwardDeleteWord ``` It works in terminal as expected. Though ctrl+w can work as expected if I add one line, the ctrl+j cannot work, ```powershell Set-PSReadLineKeyHandler -Chord ctrl+j -Function AcceptLine ``` In powershell I can use ctrl+j instead of Enter key to run command. But in powershell in Windows Terminal this doesn't work, ctrl+j do nothing even if I mapped it to something. Other keys seem to work, I only found the binding for ctrl+j won't work. I thought terminal deals with ctrl+j itself instead of sending it to powershell, but I tried mapping ctrl+j in vim running in terminal it worked. So I don't understand why these happen, why?
claunia added the Resolution-Duplicate label 2026-01-31 00:14:15 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Dec 9, 2019):

This is probably related to PSReadline - I just tried in an application issuing raw ReadConsoleInputW calls and received the ^J out the other end as expected.

(dhowett-dev2) ~ % E:\ReadConsoleInputW.exe
UNICODE. ^Z TO EXIT
--
  REP   VK  VSC CHAR          CTRL
- --- ---- ---- ---- ---- --------
v 001 0011 001d 0000 ^@   00000008
v 001 000d 001c 000a ^J   00000008
^ 001 000d 001c 000a ^J   00000008
^ 001 0011 001d 0000 ^@   00000000

It may be a /dupe of #879.

@DHowett-MSFT commented on GitHub (Dec 9, 2019): This is probably related to PSReadline - I just tried in an application issuing raw `ReadConsoleInputW` calls and received the `^J` out the other end as expected. ``` (dhowett-dev2) ~ % E:\ReadConsoleInputW.exe UNICODE. ^Z TO EXIT -- REP VK VSC CHAR CTRL - --- ---- ---- ---- ---- -------- v 001 0011 001d 0000 ^@ 00000008 v 001 000d 001c 000a ^J 00000008 ^ 001 000d 001c 000a ^J 00000008 ^ 001 0011 001d 0000 ^@ 00000000 ``` It may be a /dupe of #879.
Author
Owner

@ghost commented on GitHub (Dec 9, 2019):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Dec 9, 2019): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5475